protected function NodeAccessBaseTableTest::assertTaxonomyPage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Tests/NodeAccessBaseTableTest.php \Drupal\node\Tests\NodeAccessBaseTableTest::assertTaxonomyPage()
Checks taxonomy/term listings to ensure only accessible nodes are listed.
Parameters
$is_admin: A boolean indicating whether the current user is an administrator. If TRUE, all nodes should be listed. If FALSE, only public nodes and the user's own private nodes should be listed.
1 call to NodeAccessBaseTableTest::assertTaxonomyPage()
- NodeAccessBaseTableTest::testNodeAccessBasic in core/
modules/ node/ src/ Tests/ NodeAccessBaseTableTest.php - Tests the "private" node access functionality.
File
- core/
modules/ node/ src/ Tests/ NodeAccessBaseTableTest.php, line 184 - Contains \Drupal\node\Tests\NodeAccessBaseTableTest.
Class
- NodeAccessBaseTableTest
- Tests behavior of the node access subsystem if the base table is not node.
Namespace
Drupal\node\TestsCode
protected function assertTaxonomyPage($is_admin) {
foreach (array(
$this->publicTid,
$this->privateTid,
) as $tid_is_private => $tid) {
$this
->drupalGet("taxonomy/term/{$tid}");
$this->nidsVisible = [];
foreach ($this
->xpath("//a[text()='Read more']") as $link) {
// See also testTranslationRendering() in NodeTranslationUITest.
$this
->assertTrue(preg_match('|node/(\\d+)$|', (string) $link['href'], $matches), 'Read more points to a node');
$this->nidsVisible[$matches[1]] = TRUE;
}
foreach ($this->nodesByUser as $uid => $data) {
foreach ($data as $nid => $is_private) {
// Private nodes should be visible on the private term page,
// public nodes should be visible on the public term page.
$should_be_visible = $tid_is_private == $is_private;
// Non-administrators can only see their own nodes on the private
// term page.
if (!$is_admin && $tid_is_private) {
$should_be_visible = $should_be_visible && $uid == $this->webUser
->id();
}
$this
->assertIdentical(isset($this->nidsVisible[$nid]), $should_be_visible, strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', array(
'%private' => $is_private ? 'private' : 'public',
'%uid' => $uid,
'%visible' => isset($this->nidsVisible[$nid]) ? 'visible' : 'not visible',
'%current_uid' => $this->webUser
->id(),
'%tid_is_private' => $tid_is_private ? 'private' : 'public',
)));
}
}
}
}