function EntityMaskTest::testViewDisplays

Same name in other branches
  1. 8.x-3.x modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php \Drupal\Tests\ctools_entity_mask\Kernel\EntityMaskTest::testViewDisplays()

Tests that entity view displays are correctly masked.

File

modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php, line 59

Class

EntityMaskTest
Basic test of entity type masking.

Namespace

Drupal\Tests\ctools_entity_mask\Kernel

Code

public function testViewDisplays() {
    $view_modes = $this->container
        ->get('entity_display.repository')
        ->getAllViewModes();
    $this->assertSame($view_modes['block_content'], $view_modes['fake_block_content']);
    $storage = $this->container
        ->get('entity_type.manager')
        ->getStorage('entity_view_display');
    $display = $storage->create([
        'targetEntityType' => 'fake_block_content',
        'bundle' => 'basic',
        'mode' => 'default',
        'status' => TRUE,
    ]);
    $this->assertTrue($display->isNew());
    $components = $display->getComponents();
    $this->assertArrayHasKey('body', $components);
    $this->assertArrayHasKey('field_link', $components);
    $this->assertArrayHasKey('field_image', $components);
}