function ConfigEntityBaseUnitTest::testCreateDuplicate
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCreateDuplicate()
- 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCreateDuplicate()
- 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCreateDuplicate()
@covers ::createDuplicate
File
-
core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityBaseUnitTest.php, line 483
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testCreateDuplicate() : void {
$this->entityType
->expects($this->exactly(2))
->method('getKey')
->willReturnMap([
[
'id',
'id',
],
[
'uuid',
'uuid',
],
]);
$this->entityType
->expects($this->once())
->method('hasKey')
->with('uuid')
->willReturn(TRUE);
$new_uuid = '8607ef21-42bc-4913-978f-8c06207b0395';
$this->uuid
->expects($this->once())
->method('generate')
->willReturn($new_uuid);
$duplicate = $this->entity
->createDuplicate();
$this->assertInstanceOf('\\Drupal\\Core\\Entity\\EntityBase', $duplicate);
$this->assertNotSame($this->entity, $duplicate);
$this->assertFalse($this->entity
->isNew());
$this->assertTrue($duplicate->isNew());
$this->assertNull($duplicate->id());
$this->assertNull($duplicate->getOriginalId());
$this->assertNotEquals($this->entity
->uuid(), $duplicate->uuid());
$this->assertSame($new_uuid, $duplicate->uuid());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.