function DrupalApacheSolrNodeAccess::testIndexing in Apache Solr Search 5
Same name and namespace in other branches
- 8 apachesolr_access/tests/apachesolr_access.test \DrupalApacheSolrNodeAccess::testIndexing()
- 6.3 apachesolr_access/tests/apachesolr_access.test \DrupalApacheSolrNodeAccess::testIndexing()
- 6 contrib/apachesolr_nodeaccess/tests/apachesolr_nodeaccess.test \DrupalApacheSolrNodeAccess::testIndexing()
- 6.2 contrib/apachesolr_nodeaccess/tests/apachesolr_nodeaccess.test \DrupalApacheSolrNodeAccess::testIndexing()
- 7 apachesolr_access/tests/apachesolr_access.test \DrupalApacheSolrNodeAccess::testIndexing()
File
- contrib/
apachesolr_nodeaccess/ tests/ apachesolr_nodeaccess.test, line 28
Class
Code
function testIndexing() {
$basic_user = $this->basic_user;
// Login as basic user to perform initial content creation.
$this
->drupalLoginUser($basic_user);
//Create 2 nodes
$role_restricted_node = new StdClass();
$role_restricted_node->title = $this
->randomName(32);
$role_restricted_node->body = $this
->randomName(32);
$role_restricted_node->comment = 2;
$role_restricted_node->changed = time();
$role_restricted_node->format = FILTER_FORMAT_DEFAULT;
$role_restricted_node->moderate = 0;
$role_restricted_node->promote = 0;
$role_restricted_node->revision = 1;
$role_restricted_node->log = '';
$role_restricted_node->status = 1;
$role_restricted_node->sticky = 0;
$role_restricted_node->type = 'page';
$role_restricted_node->revisions = NULL;
$role_restricted_node->taxonomy = NULL;
node_save($node);
$author_restricted_node = new StdClass();
$author_restricted_node->title = $this
->randomName(32);
$author_restricted_node->body = $this
->randomName(32);
$role_restricted_node->comment = 2;
$role_restricted_node->changed = time();
$role_restricted_node->format = FILTER_FORMAT_DEFAULT;
$role_restricted_node->moderate = 0;
$role_restricted_node->promote = 0;
$role_restricted_node->revision = 1;
$role_restricted_node->log = '';
$role_restricted_node->status = 1;
$role_restricted_node->sticky = 0;
$role_restricted_node->type = 'page';
$role_restricted_node->revisions = NULL;
$role_restricted_node->taxonomy = NULL;
node_save($node);
// No Drupal Logout in SimpleTest 1 $this->drupalLogout();
$roles = array_keys($basic_user->roles);
// The assigned role will be the last in the array.
$assigned_role = end($roles);
$role_grant = array(
'gid' => $assigned_role,
'realm' => 'nodeaccess_rid',
'grant_view' => '1',
'grant_update' => '0',
'grant_delete' => '0',
);
node_access_write_grants($role_restricted_node, array(
$role_grant,
), "nodeaccess_rid");
$author_grant = array(
'gid' => $basic_user->uid,
'realm' => 'nodeaccess_author',
'grant_view' => '1',
'grant_update' => '0',
'grant_delete' => '0',
);
node_access_write_grants($author_restricted_node, array(
$author_grant,
), "nodeaccess_author");
$include_path = get_include_path();
set_include_path('./' . drupal_get_path('module', 'apachesolr') . '/SolrPhpClient/');
include_once 'Apache/Solr/Service.php';
set_include_path($include_path);
$document = new Apache_Solr_Document();
apachesolr_nodeaccess_apachesolr_update_index($document, $role_restricted_node);
$this
->assertEqual($document->nodeaccess_nodeaccess_rid[0], $assigned_role, "Solr Document being indexed is restricted by the proper role");
$document = new Apache_Solr_Document();
apachesolr_nodeaccess_apachesolr_update_index($document, $author_restricted_node);
$this
->assertEqual($document->nodeaccess_nodeaccess_author[0], $basic_user->uid, "Solr Document being indexed is restricted by the proper author");
}