Same name in other branches
- 2.x tests/src/Functional/EntityCloneEntityViewModeTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneEntityViewModeTest
Test an entity view mode clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneEntityViewModeTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneEntityViewModeTest
File
-
tests/
src/ Functional/ EntityCloneEntityViewModeTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneEntityViewModeTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'field_ui',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'clone entity_view_mode entity',
'administer display modes',
];
/**
* An administrative user.
*
* With permission to configure entity view modes settings.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Sets the test up.
*/
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalLogin($this->adminUser);
}
/**
* Test entity view mode entity clone.
*/
public function testEntityViewModeEntityClone() {
$entity_view_modes = \Drupal::entityTypeManager()->getStorage('entity_view_mode')
->loadByProperties([
'id' => 'user.full',
]);
$entity_view_mode = reset($entity_view_modes);
$edit = [
'label' => 'User full cloned view mode',
'id' => 'register_clone',
];
$this->drupalGet('entity_clone/entity_view_mode/' . $entity_view_mode->id());
$this->submitForm($edit, $this->t('Clone'));
$entity_view_modes = \Drupal::entityTypeManager()->getStorage('entity_view_mode')
->loadByProperties([
'id' => 'user.' . $edit['id'],
]);
$entity_view_mode = reset($entity_view_modes);
$this->assertInstanceOf(EntityViewMode::class, $entity_view_mode, 'Test entity view mode cloned found in database.');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EntityCloneEntityViewModeTest::$adminUser | protected | property | An administrative user. |
EntityCloneEntityViewModeTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneEntityViewModeTest::$modules | protected static | property | Modules to enable. |
EntityCloneEntityViewModeTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneEntityViewModeTest::setUp | protected | function | Sets the test up. |
EntityCloneEntityViewModeTest::testEntityViewModeEntityClone | public | function | Test entity view mode entity clone. |