function SearchByPageUsersReindexTest::testReindexingOnUpdate in Search by Page 6
Same name and namespace in other branches
- 7 tests/search_by_page.test \SearchByPageUsersReindexTest::testReindexingOnUpdate()
Tests that user reindexing happens in the right order on user update.
File
- tests/
search_by_page.test, line 1090 - Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageUsersReindexTest
- Tests when users are reindexed.
Code
function testReindexingOnUpdate() {
$this
->drupalLogin($this->superuser);
$search_path = $this->envinfo2['page_path'];
// Set to never reindex automatically.
$this
->drupalPost('admin/settings/search_by_page/edit/' . $this->envid2, array(
'sbp_users_min_time' => 0,
'sbp_users_max_time' => 0,
), 'Save configuration');
cache_clear_all('variables', 'cache');
variable_init();
// Set search so it only indexes 1 user per cron run.
variable_set('sbp_cron_limit', 1);
// Run this test several times...
for ($j = 0; $j < 10; $j++) {
// Choose a random user name.
$newname = $this
->randomName();
$i = rand(0, count($this->users) - 1);
user_save($this->users[$i], array(
'name' => $newname,
));
// Verify user can be loaded and has right name.
$acct = user_load($this->users[$i]->uid);
$this
->assertEqual($acct->name, $newname, "New user name was saved");
// Verify new name shows on user page
$this
->drupalGet('user/' . $this->users[$i]->uid);
$this
->assertText($newname, 'New user name appears on user page');
// Verify new name is not searchable.
$this
->drupalPost($search_path, array(
'keys' => $newname,
), t('Search pages'));
$this
->assertNoText($newname, 'New user name not found in search');
// Run cron - should reindex just this user.
$this
->doCronrun();
$this
->drupalLogin($this->superuser);
$this
->drupalGet('admin/reports/dblog');
$this
->assertText(t('Cron run completed'), 'Log shows cron run completed');
// Verify new name is searchable.
$this
->drupalPost($search_path, array(
'keys' => $newname,
), t('Search pages'));
$this
->assertText($newname, 'New user name found in search after reindex');
}
}