function MigrateContactCategoryTest::testContactCategory

Same name in other branches
  1. 9 core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest::testContactCategory()
  2. 8.9.x core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest::testContactCategory()
  3. 10 core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php \Drupal\Tests\contact\Kernel\Migrate\MigrateContactCategoryTest::testContactCategory()

The Drupal 6 and 7 contact categories to Drupal 8 migration.

File

core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php, line 60

Class

MigrateContactCategoryTest
Migrate contact categories to contact.form.*.yml.

Namespace

Drupal\Tests\contact\Kernel\Migrate

Code

public function testContactCategory() : void {
    $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.