function NodeQueryAlterTest::testNodeQueryAlterWithUI

Tests that node access permissions are followed.

File

drupal/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php, line 61
Definition of Drupal\node\Tests\NodeQueryAlterTest.

Class

NodeQueryAlterTest
Tests node_query_node_access_alter().

Namespace

Drupal\node\Tests

Code

function testNodeQueryAlterWithUI() {

  // Verify that a user with access permission can see at least one node.
  $this
    ->drupalLogin($this->accessUser);
  $this
    ->drupalGet('node_access_test_page');
  $this
    ->assertText('Yes, 4 nodes', "4 nodes were found for access user");
  $this
    ->assertNoText('Exception', "No database exception");

  // Test the content overview page.
  $this
    ->drupalGet('admin/content');
  $table_rows = $this
    ->xpath('//tbody/tr');
  $this
    ->assertEqual(4, count($table_rows), "4 nodes were found for access user");

  // Verify that a user with no access permission cannot see nodes.
  $this
    ->drupalLogin($this->noAccessUser);
  $this
    ->drupalGet('node_access_test_page');
  $this
    ->assertText('No nodes', "No nodes were found for no access user");
  $this
    ->assertNoText('Exception', "No database exception");
  $this
    ->drupalGet('admin/content');
  $this
    ->assertText(t('No content available.'));
}