public function EntityUnitTest::testLabel in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::testLabel()
@covers ::label
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityUnitTest.php, line 170
Class
- EntityUnitTest
- @coversDefaultClass \Drupal\Core\Entity\EntityBase @group Entity @group Access
Namespace
Drupal\Tests\Core\EntityCode
public function testLabel() {
$property_label = $this
->randomMachineName();
$this->entityType
->expects($this
->atLeastOnce())
->method('getKey')
->with('label')
->will($this
->returnValue('label'));
// Set a dummy property on the entity under test to test that the label can
// be returned form a property if there is no callback.
$this->entityTypeManager
->expects($this
->atLeastOnce())
->method('getDefinition')
->with($this->entityTypeId)
->will($this
->returnValue([
'entity_keys' => [
'label' => 'label',
],
]));
$this->entity->label = $property_label;
$this
->assertSame($property_label, $this->entity
->label());
}