You are here

function TrackerTest::assertHistoryMetadata in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/tracker/src/Tests/TrackerTest.php \Drupal\tracker\Tests\TrackerTest::assertHistoryMetadata()

Passes if the appropriate history metadata exists.

Verify the data-history-node-id, data-history-node-timestamp and data-history-node-last-comment-timestamp attributes, which are used by the drupal.tracker-history library to add the appropriate "new" and "updated" indicators, as well as the "x new" replies link to the tracker. We do this in JavaScript to prevent breaking the render cache.

Parameters

$node_id: A node ID, that must exist as a data-history-node-id attribute

$node_timestamp: A node timestamp, that must exist as a data-history-node-timestamp attribute.

$node_last_comment_timestamp: A node's last comment timestamp, that must exist as a data-history-node-last-comment-timestamp attribute.

bool $library_is_present: Whether the drupal.tracker-history library should be present or not.

1 call to TrackerTest::assertHistoryMetadata()
TrackerTest::testTrackerHistoryMetadata in core/modules/tracker/src/Tests/TrackerTest.php
Tests the metadata for the "new"/"updated" indicators.

File

core/modules/tracker/src/Tests/TrackerTest.php, line 446
Contains \Drupal\tracker\Tests\TrackerTest.

Class

TrackerTest
Create and delete nodes and check for their display in the tracker listings.

Namespace

Drupal\tracker\Tests

Code

function assertHistoryMetadata($node_id, $node_timestamp, $node_last_comment_timestamp, $library_is_present = TRUE) {
  $settings = $this
    ->getDrupalSettings();
  $this
    ->assertIdentical($library_is_present, isset($settings['ajaxPageState']) && in_array('tracker/history', explode(',', $settings['ajaxPageState']['libraries'])), 'drupal.tracker-history library is present.');
  $this
    ->assertIdentical(1, count($this
    ->xpath('//table/tbody/tr/td[@data-history-node-id="' . $node_id . '" and @data-history-node-timestamp="' . $node_timestamp . '"]')), 'Tracker table cell contains the data-history-node-id and data-history-node-timestamp attributes for the node.');
  $this
    ->assertIdentical(1, count($this
    ->xpath('//table/tbody/tr/td[@data-history-node-last-comment-timestamp="' . $node_last_comment_timestamp . '"]')), 'Tracker table cell contains the data-history-node-last-comment-timestamp attribute for the node.');
}