function ContentEntityChangedTest::testChangedSyncing

Tests the changed functionality when an entity is syncing.

File

core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php, line 477

Class

ContentEntityChangedTest
Tests basic EntityChangedInterface functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testChangedSyncing() : void {
    $entity = EntityTestMulChanged::create();
    $entity->save();
    $changed_time_1 = $entity->getChangedTime();
    // Without the syncing flag the changed time will increment when content is
    // changed.
    $entity->setName($this->randomString());
    $entity->save();
    $changed_time_2 = $entity->getChangedTime();
    $this->assertTrue($changed_time_2 > $changed_time_1);
    // With the syncing flag, the changed time will not change.
    $entity->setName($this->randomString());
    $entity->setSyncing(TRUE);
    $entity->save();
    $changed_time_3 = $entity->getChangedTime();
    $this->assertEquals($changed_time_2, $changed_time_3);
}

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