Commit 30a45ade authored by alexpott's avatar alexpott

Issue #1987758 by juampy, Niklas Fiekas: Remove node_access_test_page().

parent 2c2f5f59
......@@ -62,20 +62,4 @@ function setUp() {
$this->noAccessUser = $this->drupalCreateUser(array('access content'));
}
/**
* Tests that node access permissions are followed.
*/
function testNodeQueryAlterWithUI() {
// Verify that a user with access permission can see at least one node.
$this->drupalLogin($this->accessUser);
$this->drupalGet('node_access_entity_test_page');
$this->assertText('Yes, 4 nodes', "4 nodes were found for access user");
$this->assertNoText('Exception', "No database exception");
// Verify that a user with no access permission cannot see nodes.
$this->drupalLogin($this->noAccessUser);
$this->drupalGet('node_access_entity_test_page');
$this->assertText('No nodes', "No nodes were found for no access user");
$this->assertNoText('Exception', "No database exception");
}
}
......@@ -55,31 +55,6 @@ function setUp() {
$this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content'));
}
/**
* Tests that node access permissions are followed.
*/
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.'));
}
/**
* Tests 'node_access' query alter, for user with access.
*
......
......@@ -76,107 +76,6 @@ function node_access_test_permission() {
return array('node test view' => array('title' => 'View content'));
}
/**
* Implements hook_menu().
*
* Sets up a test page that lists nodes.
*/
function node_access_test_menu() {
$items = array();
$items['node_access_test_page'] = array(
'title' => 'Node access test',
'page callback' => 'node_access_test_page',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
);
$items['node_access_entity_test_page'] = array(
'title' => 'Node access test',
'page callback' => 'node_access_entity_test_page',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
);
return $items;
}
/**
* Page callback: Creates the node access test page.
*
* Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with
* the number filled in) if there were nodes the user could access. Also, the
* database query is shown, and a list of the node IDs, for debugging purposes.
* And if there is a query exception, the page says "Exception" and gives the
* error.
*
* @see node_access_test_menu()
*/
function node_access_test_page() {
$output = '';
try {
$query = db_select('node', 'mytab')
->fields('mytab');
$query->addTag('node_access');
$result = $query->execute()->fetchAll();
if (count($result)) {
$output .= '<p>Yes, ' . count($result) . ' nodes</p>';
$output .= '<ul>';
foreach ($result as $item) {
$output .= '<li>' . $item->nid . '</li>';
}
$output .= '</ul>';
}
else {
$output .= '<p>No nodes</p>';
}
$output .= '<p>' . ((string) $query ) . '</p>';
}
catch (Exception $e) {
$output = '<p>Exception</p>';
$output .= '<p>' . $e->getMessage() . '</p>';
}
return $output;
}
/**
* Page callback: Creates the node access entity test page.
*
* Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with
* the number filled in) if there were nodes the user could access. Also, the
* database query is shown, and a list of the node IDs, for debugging purposes.
* And if there is a query exception, the page says "Exception" and gives the
* error.
*
* @see node_access_test_menu()
*/
function node_access_entity_test_page() {
$output = '';
try {
$result = Drupal::entityQuery('node')
->condition('body.value', 'A', 'STARTS_WITH')
->execute();
if (!empty($result)) {
$output .= '<p>Yes, ' . count($result) . ' nodes</p>';
$output .= '<ul>';
foreach ($result as $nid) {
$output .= '<li>' . $nid . '</li>';
}
$output .= '</ul>';
}
else {
$output .= '<p>No nodes</p>';
}
}
catch (Exception $e) {
$output = '<p>Exception</p>';
$output .= '<p>' . $e->getMessage() . '</p>';
}
return $output;
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment