function ConfigEntityBaseUnitTest::testToArrayIdKey
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testToArrayIdKey()
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testToArrayIdKey()
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testToArrayIdKey()
@covers ::toArray
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 572
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testToArrayIdKey() : void {
$entity = $this->getMockBuilder(ConfigEntityBaseMockableClass::class)
->setConstructorArgs([
[],
$this->entityTypeId,
])
->onlyMethods([
'id',
'get',
])
->getMock();
$entity->expects($this->atLeastOnce())
->method('id')
->willReturn($this->id);
$entity->expects($this->once())
->method('get')
->with('dependencies')
->willReturn([]);
$this->typedConfigManager
->expects($this->never())
->method('getDefinition');
$this->entityType
->expects($this->any())
->method('getPropertiesToExport')
->willReturn([
'id' => 'configId',
'dependencies' => 'dependencies',
]);
$this->entityType
->expects($this->once())
->method('getKey')
->with('id')
->willReturn('id');
$properties = $entity->toArray();
$this->assertIsArray($properties);
$this->assertEquals([
'configId' => $entity->id(),
'dependencies' => [],
], $properties);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.