public function EntityDisplayModeBaseUnitTest::testSetTargetType in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testSetTargetType()
- 10 core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\EntityDisplayModeBaseUnitTest::testSetTargetType()
@covers ::setTargetType
File
- core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ EntityDisplayModeBaseUnitTest.php, line 105
Class
- EntityDisplayModeBaseUnitTest
- @coversDefaultClass \Drupal\Core\Entity\EntityDisplayModeBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testSetTargetType() {
// Generate mock.
$mock = $this
->getMockBuilder('Drupal\\Core\\Entity\\EntityDisplayModeBase')
->setMethods(NULL)
->setConstructorArgs([
[
'something' => 'nothing',
],
'test_type',
])
->getMock();
// Some test values.
$bad_target = 'uninitialized';
$target = 'test_target_type';
// Gain access to the protected property.
$property = new \ReflectionProperty($mock, 'targetEntityType');
$property
->setAccessible(TRUE);
// Set the property to a known state.
$property
->setValue($mock, $bad_target);
// Set the target type.
$mock
->setTargetType($target);
// Test the outcome.
$this
->assertNotEquals($bad_target, $property
->getValue($mock));
$this
->assertEquals($target, $property
->getValue($mock));
}