public function SearchByPageNodesReindexTest::setUp in Search by Page 6
Same name and namespace in other branches
- 7 tests/search_by_page.test \SearchByPageNodesReindexTest::setUp()
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
File
- tests/
search_by_page.test, line 702 - Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageNodesReindexTest
- Tests when nodes are reindexed.
Code
public function setUp() {
parent::setUp('search', 'search_by_page', 'sbp_nodes', 'sbp_test', 'dblog', 'comment');
// Note: I think SimpleTest inherits the default node access from the
// base system. Needs to be rebuilt in order for the access tests below
// to pass!
node_access_rebuild();
$this
->setUpEnvironments();
// Set up super-user.
$this->superuser = $this
->drupalCreateUser(array(
'administer nodes',
'access content',
'administer content types',
'administer blocks',
'administer search',
'search content',
'administer search by page',
'access administration pages',
$this
->searchPerm($this->envinfo1),
'administer site configuration',
'administer users',
'administer permissions',
'view test private content',
'access site reports',
'access comments',
'post comments without approval',
'administer comments',
));
$this
->drupalLogin($this->superuser);
// Set up so "sbp_indexed" nodes are searchable.
// Index them with the super-user.
$this
->drupalPost('admin/settings/search_by_page/edit/' . $this->envid1, array(
'sbp_nodes_types_indexed[sbp_indexed]' => TRUE,
'sbp_nodes_display_type' => 'excerpts',
'sbp_nodes_role' => $this
->getNewRoleID($this->superuser),
'button_label' => t('Search pages'),
), 'Save configuration');
cache_clear_all('variables', 'cache');
variable_init();
// Create 5 nodes with the same content.
$info = array(
'body' => 'blah',
'teaser' => 'blah',
'title' => 'blah',
'type' => 'sbp_indexed',
'test_private' => FALSE,
);
$this->nodes = array();
for ($i = 0; $i < 5; $i++) {
$this->nodes[] = $this
->drupalCreateNode($info);
}
// Run cron to index these nodes.
$this
->doCronrun();
$this
->drupalLogin($this->superuser);
$this
->drupalGet('admin/reports/dblog');
$this
->assertText(t('Cron run completed'), 'Log shows cron run completed');
$this
->drupalLogout();
}