function SearchByPageNodesReindexTest::testReindexingOnUpdate in Search by Page 6
Same name and namespace in other branches
- 7 tests/search_by_page.test \SearchByPageNodesReindexTest::testReindexingOnUpdate()
Tests that node reindexing happens in the right order on node update.
File
- tests/
search_by_page.test, line 763 - Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageNodesReindexTest
- Tests when nodes are reindexed.
Code
function testReindexingOnUpdate() {
$this
->drupalLogin($this->superuser);
$search_path = $this->envinfo1['page_path'];
// Set to never reindex automatically.
$this
->drupalPost('admin/settings/search_by_page/edit/' . $this->envid1, array(
'sbp_nodes_min_time' => 0,
'sbp_nodes_max_time' => 0,
), 'Save configuration');
cache_clear_all('variables', 'cache');
variable_init();
// Set search so it only indexes 1 node per cron run.
variable_set('sbp_cron_limit', 1);
// Run this test several times...
for ($j = 0; $j < 10; $j++) {
// Choose a random title and index.
$newtitle = $this
->randomName();
$i = rand(0, count($this->nodes) - 1);
$this->nodes[$i]->title = $newtitle;
node_save($this->nodes[$i]);
// Verify new title is not searchable.
$this
->drupalPost($search_path, array(
'keys' => $newtitle,
), t('Search pages'));
$this
->assertNoText($newtitle, 'New title not found in search');
// Run cron - should reindex just this node.
$this
->doCronrun();
$this
->drupalLogin($this->superuser);
// Verify new title is searchable.
$this
->drupalPost($search_path, array(
'keys' => $newtitle,
), t('Search pages'));
$this
->assertText($newtitle, 'New title found in search after reindex');
}
}