NodeFormSaveChangedTimeTest.php in Zircon Profile 8.0
File
core/modules/node/src/Tests/NodeFormSaveChangedTimeTest.php
View source
<?php
namespace Drupal\node\Tests;
use Drupal\simpletest\WebTestBase;
class NodeFormSaveChangedTimeTest extends WebTestBase {
public static $modules = array(
'node',
);
protected $authorUser;
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
$this->authorUser = $this
->drupalCreateUser([
'access content',
'create article content',
'edit any article content',
], 'author');
$this
->drupalLogin($this->authorUser);
$this
->drupalCreateNode(array(
'type' => 'article',
));
}
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.");
sleep(1);
$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.");
}
}