Skip to content

Commit

Permalink
refactor: removed deprecated REQUEST_TIME on test file
Browse files Browse the repository at this point in the history
  • Loading branch information
w-lopes committed Jan 21, 2022
1 parent 72975a0 commit 53de3bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Tests/PublicationDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public function setUp() {
* Test automatic saving of variables.
*/
public function testActionSaving() {
$requestTime = \Drupal::time()->getRequestTime();

// Create node to edit.
$node = $this->drupalCreateNode(array('status' => 0));
$unpublished_node = node_load($node->id());
$this->assertTrue(empty($unpublished_node->published_at->value), 'Published date is initially empty');
$this->assertTrue($unpublished_node->published_at->published_at_or_now == REQUEST_TIME,
$this->assertTrue($unpublished_node->published_at->published_at_or_now == $requestTime,
'Published at or now date is REQUEST_TIME');

// Publish the node.
Expand All @@ -61,7 +62,7 @@ public function testActionSaving() {
$published_node = node_load($node->id());
$this->assertTrue(is_numeric($published_node->published_at->value),
'Published date is integer/numberic once published');
$this->assertTrue($published_node->published_at->value == REQUEST_TIME,
$this->assertTrue($published_node->published_at->value == $requestTime,
'Published date is REQUEST_TIME');
$this->assertTrue($unpublished_node->published_at->published_at_or_now == $published_node->published_at->value,
'Published at or now date equals published date');
Expand Down Expand Up @@ -146,7 +147,7 @@ public function testActionSavingOnForms() {
t('Pubdate is maintained when republished'));

// Set a custom time and make sure that it is stored correctly.
$ctime = REQUEST_TIME - 180;
$ctime = \Drupal::time()->getRequestTime() - 180;
$edit['pubdate'] = format_date($ctime, 'custom', 'Y-m-d H:i:s O');
$this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->id() . '/edit');
Expand Down

0 comments on commit 53de3bf

Please sign in to comment.