MigrateViewModesTest.php
Same filename in this branch
Same filename in other branches
- 8.9.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateViewModesTest.php
- 8.9.x core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
- 10 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateViewModesTest.php
- 10 core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
- 11.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateViewModesTest.php
- 11.x core/modules/node/tests/src/Kernel/Migrate/d6/MigrateViewModesTest.php
Namespace
Drupal\Tests\field\Kernel\Migrate\d7File
-
core/
modules/ field/ tests/ src/ Kernel/ Migrate/ d7/ MigrateViewModesTest.php
View source
<?php
namespace Drupal\Tests\field\Kernel\Migrate\d7;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\Core\Entity\EntityViewModeInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests migration of D7 view modes.
*
* @group field
*/
class MigrateViewModesTest extends MigrateDrupal7TestBase {
protected static $modules = [
'comment',
'node',
'taxonomy',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('comment');
$this->installEntitySchema('node');
$this->executeMigration('d7_view_modes');
}
/**
* Asserts various aspects of a view mode entity.
*
* @param string $id
* The entity ID.
* @param string $label
* The expected label of the view mode.
* @param string $entity_type
* The expected entity type ID which owns the view mode.
*
* @internal
*/
protected function assertEntity(string $id, string $label, string $entity_type) : void {
/** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
$view_mode = EntityViewMode::load($id);
$this->assertInstanceOf(EntityViewModeInterface::class, $view_mode);
$this->assertSame($label, $view_mode->label());
$this->assertSame($entity_type, $view_mode->getTargetType());
}
/**
* Tests migration of D7 view mode variables to D8 config entities.
*/
public function testMigration() {
$this->assertEntity('comment.full', 'Full', 'comment');
$this->assertEntity('node.teaser', 'Teaser', 'node');
$this->assertEntity('node.full', 'Full', 'node');
$this->assertEntity('node.custom', 'custom', 'node');
$this->assertEntity('user.full', 'Full', 'user');
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
MigrateViewModesTest | Tests migration of D7 view modes. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.