public function NodeFormSaveChangedTimeTest::testChangedTimeAfterSaveWithoutChanges in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Tests/NodeFormSaveChangedTimeTest.php \Drupal\node\Tests\NodeFormSaveChangedTimeTest::testChangedTimeAfterSaveWithoutChanges()
Test the changed time after API and FORM save without changes.
File
- core/
modules/ node/ src/ Tests/ NodeFormSaveChangedTimeTest.php, line 59 - Contains \Drupal\node\Tests\NodeFormSaveChangedTimeTest.
Class
- NodeFormSaveChangedTimeTest
- Tests updating the changed time after API and FORM entity save.
Namespace
Drupal\node\TestsCode
public function testChangedTimeAfterSaveWithoutChanges() {
$node = entity_load('node', 1);
$changed_timestamp = $node
->getChangedTime();
$node
->save();
$node = entity_load('node', 1, TRUE);
$this
->assertEqual($changed_timestamp, $node
->getChangedTime(), "The entity's changed time wasn't updated after API save without changes.");
// Ensure different save timestamps.
sleep(1);
// Save the node on the regular node edit form.
$this
->drupalPostForm('node/1/edit', array(), t('Save'));
$node = entity_load('node', 1, TRUE);
$this
->assertNotEqual($changed_timestamp, $node
->getChangedTime(), "The entity's changed time was updated after form save without changes.");
}