summaryrefslogtreecommitdiff
path: root/modules/node/tests
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-08-22 16:11:12 +0000
committerDries Buytaert <dries@buytaert.net>2010-08-22 16:11:12 +0000
commit479b71232be6634e59868d72471d798c4fbabfce (patch)
tree5c5e336e374acf9792b7da6c390d75cc43c71439 /modules/node/tests
parent1651cf34bfbdf02f6c03f8d00b025a610d24df23 (diff)
downloadbrdo-479b71232be6634e59868d72471d798c4fbabfce.tar.gz
brdo-479b71232be6634e59868d72471d798c4fbabfce.tar.bz2
- Patch #860180 by chx, dixon_, jhodgdon: entity listing and loading does not allow for node access.
Diffstat (limited to 'modules/node/tests')
-rw-r--r--modules/node/tests/node_access_test.module40
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/node/tests/node_access_test.module b/modules/node/tests/node_access_test.module
index eaae6b80a..ac71667ef 100644
--- a/modules/node/tests/node_access_test.module
+++ b/modules/node/tests/node_access_test.module
@@ -58,6 +58,12 @@ function node_access_test_menu() {
'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;
}
@@ -100,3 +106,37 @@ function node_access_test_page() {
return $output;
}
+
+/**
+ * Page callback for 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.
+ */
+function node_access_entity_test_page() {
+ $output = '';
+ try {
+ $query = new EntityFieldQuery;
+ $result = $query->fieldCondition('body', 'value', 'A', 'STARTS_WITH')->execute();
+ if (!empty($result['node'])) {
+ $output .= '<p>Yes, ' . count($result['node']) . ' nodes</p>';
+ $output .= '<ul>';
+ foreach ($result['node'] as $nid => $v) {
+ $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;
+}