function LegacyEntityDisplayBaseTest::testHandleHiddenType

Tests the deprecated ::handleHiddenType() method.

@expectedDeprecation Drupal\Core\Entity\EntityDisplayBase::handleHiddenType is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. No replacement is provided. See https://www.drupal.org/node/2801513

File

core/tests/Drupal/KernelTests/Core/Entity/LegacyEntityDisplayBaseTest.php, line 84

Class

LegacyEntityDisplayBaseTest
Tests Deprecated EntityDisplayBase functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testHandleHiddenType() {
    $entity_display = EntityViewDisplay::create([
        'targetEntityType' => 'entity_test',
        'bundle' => 'entity_test',
        'mode' => 'default',
        'status' => TRUE,
        'content' => [
            'foo' => [
                'type' => 'visible',
            ],
            'bar' => [
                'type' => 'hidden',
            ],
            'name' => [
                'type' => 'hidden',
                'region' => 'content',
            ],
        ],
    ]);
    $method = new \ReflectionMethod($entity_display, 'handleHiddenType');
    $method->setAccessible(TRUE);
    $this->assertSame([
        'type' => 'hidden',
    ], $entity_display->getComponent('bar'));
    $method->invoke($entity_display, 'bar', [
        'type' => 'hidden',
    ]);
    $this->assertNull($entity_display->getComponent('bar'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.