class MigrateContactCategoryTest
Same name and namespace in other branches
- 11.x core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest
- 10 core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest
- 8.9.x core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest
Migrate contact categories to contact.form.*.yml.
@group contact_category
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase implements \Drupal\migrate\MigrateMessageInterface extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase extends \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait extends \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest extends \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait extends \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase extends \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase implements \Drupal\migrate\MigrateMessageInterface extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of MigrateContactCategoryTest
File
-
core/
modules/ contact/ tests/ src/ Kernel/ Migrate/ MigrateContactCategoryTest.php, line 14
Namespace
Drupal\Tests\contact\Kernel\MigrateView source
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'contact',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->executeMigration('contact_category');
}
/**
* Performs various assertions on a single contact form entity.
*
* @param string $id
* The contact form ID.
* @param string $expected_label
* The expected label.
* @param string[] $expected_recipients
* The recipient e-mail addresses the form should have.
* @param string $expected_reply
* The expected reply message.
* @param int $expected_weight
* The contact form's expected weight.
*
* @internal
*/
protected function assertEntity(string $id, string $expected_label, array $expected_recipients, string $expected_reply, int $expected_weight) : void {
/** @var \Drupal\contact\ContactFormInterface $entity */
$entity = ContactForm::load($id);
$this->assertInstanceOf(ContactFormInterface::class, $entity);
$this->assertSame($expected_label, $entity->label());
$this->assertSame($expected_recipients, $entity->getRecipients());
$this->assertSame($expected_reply, $entity->getReply());
$this->assertSame($expected_weight, $entity->getWeight());
}
/**
* The Drupal 6 and 7 contact categories to Drupal 8 migration.
*/
public function testContactCategory() {
$this->assertEntity('website_feedback', 'Website feedback', [
'admin@example.com',
], '', 0);
$this->assertEntity('some_other_category', 'Some other category', [
'test@example.com',
], 'Thanks for contacting us, we will reply ASAP!', 1);
$this->assertEntity('a_category_much_longer_than_th', 'A category much longer than thirty two characters', [
'fortyninechars@example.com',
], '', 2);
// Test there are no duplicated roles.
$contact_forms = [
'website_feedback1',
'some_other_category1',
'a_category_much_longer_than_thir1',
];
$this->assertEmpty(ContactForm::loadMultiple($contact_forms));
/*
* Remove the map row for the Website feedback contact form so that it
* can be migrated again.
*/
$id_map = $this->getMigration('contact_category')
->getIdMap();
$id_map->delete([
'cid' => '1',
]);
$this->executeMigration('contact_category');
// Test there is a duplicate Website feedback form.
$this->assertEntity('website_feedback1', 'Website feedback', [
'admin@example.com',
], '', 0);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.