public function ConfigEntityBaseUnitTest::testCreateDuplicate in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCreateDuplicate()
- 10 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 478 - Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.
Class
- ConfigEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
public function testCreateDuplicate() {
$this->entityType
->expects($this
->at(0))
->method('getKey')
->with('id')
->will($this
->returnValue('id'));
$this->entityType
->expects($this
->at(1))
->method('hasKey')
->with('uuid')
->will($this
->returnValue(TRUE));
$this->entityType
->expects($this
->at(2))
->method('getKey')
->with('uuid')
->will($this
->returnValue('uuid'));
$new_uuid = '8607ef21-42bc-4913-978f-8c06207b0395';
$this->uuid
->expects($this
->once())
->method('generate')
->will($this
->returnValue($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());
}