function EntityDisplayModeBaseUnitTest::testGetTargetType

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testGetTargetType()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testGetTargetType()
  3. 10 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testGetTargetType()

@covers ::getTargetType

File

core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php, line 131

Class

EntityDisplayModeBaseUnitTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityDisplayModeBase.php/class/EntityDisplayModeBase/11.x" title="Base class for config entity types with settings for form and view modes." class="local">\Drupal\Core\Entity\EntityDisplayModeBase</a> @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testGetTargetType() : void {
    // Generate mock.
    $mock = $this->getMockBuilder('Drupal\\Core\\Entity\\EntityDisplayModeBase')
        ->onlyMethods([])
        ->setConstructorArgs([
        [
            'something' => 'nothing',
        ],
        'test_type',
    ])
        ->getMock();
    // A test value.
    $target = 'test_target_type';
    // Gain access to the protected property.
    $property = new \ReflectionProperty($mock, 'targetEntityType');
    // Set the property to a known state.
    $property->setValue($mock, $target);
    // Get the target type.
    $value = $mock->getTargetType($target);
    // Test the outcome.
    $this->assertEquals($value, $property->getValue($mock));
}

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