function ConfigEntityBaseUnitTest::testGetOriginalId

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testGetOriginalId()
  2. 10 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testGetOriginalId()
  3. 11.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testGetOriginalId()

@covers ::setOriginalId @covers ::getOriginalId

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 391

Class

ConfigEntityBaseUnitTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testGetOriginalId() {
    $new_id = $this->randomMachineName();
    $this->entity
        ->set('id', $new_id);
    $this->assertSame($this->id, $this->entity
        ->getOriginalId());
    $this->assertSame($this->entity, $this->entity
        ->setOriginalId($new_id));
    $this->assertSame($new_id, $this->entity
        ->getOriginalId());
    // Check that setOriginalId() does not change the entity "isNew" status.
    $this->assertFalse($this->entity
        ->isNew());
    $this->entity
        ->setOriginalId($this->randomMachineName());
    $this->assertFalse($this->entity
        ->isNew());
    $this->entity
        ->enforceIsNew();
    $this->assertTrue($this->entity
        ->isNew());
    $this->entity
        ->setOriginalId($this->randomMachineName());
    $this->assertTrue($this->entity
        ->isNew());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.