function TrackerTest::assertHistoryMetadata
Same name in other branches
- 9 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::assertHistoryMetadata()
- 10 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::assertHistoryMetadata()
- 11.x core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\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
int $node_id: A node ID, that must exist as a data-history-node-id attribute
int $node_timestamp: A node timestamp, that must exist as a data-history-node-timestamp attribute.
int $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/ tests/ src/ Functional/ TrackerTest.php - Tests the metadata for the "new"/"updated" indicators.
File
-
core/
modules/ tracker/ tests/ src/ Functional/ TrackerTest.php, line 473
Class
- TrackerTest
- Create and delete nodes and check for their display in the tracker listings.
Namespace
Drupal\Tests\tracker\FunctionalCode
public 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->assertCount(1, $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->assertCount(1, $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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.