You are here

function SearchByPageExtraUsersTest::testReindexingUsers in Search by Page 7

Tests that no new users are created when reindexing.

File

tests/search_by_page.test, line 1007
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageExtraUsersTest
Tests that no extra Search by Page indexing users are created.

Code

function testReindexingUsers() {
  $this
    ->drupalLogin($this->superuser);
  $search_path = $this->envinfo1['page_path'];

  // Count the number of users.
  $num_before = $this
    ->howManyUsers();

  // Set to reindex automatically on normal cycle.
  $this
    ->drupalPost('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'sbp_nodes_min_time' => 1,
    'sbp_nodes_max_time' => 0,
  ), 'Save configuration');
  cache_clear_all('variables', 'cache');
  variable_initialize();

  // Set search so it only indexes 1 node per cron run.
  variable_set('sbp_cron_limit', 1);

  // Figure out the current index times of the nodes.
  $orig = $this
    ->getIndexTimes();

  // In a loop: run cron, and verify each time that something was reindexed.
  for ($i = 0; $i < 10; $i++) {

    // Run cron - should reindex just one node.
    $this
      ->doCronrun();
    $this
      ->drupalLogin($this->superuser);

    // Figure out the current index times of the nodes.
    $new = $this
      ->getIndexTimes();

    // Verify that only one was indexed, and it was the oldest one.
    $this
      ->verifyIndexCycling($orig, $new);
    $orig = $new;
  }

  // Now see how many users there are.
  $num_after = $this
    ->howManyUsers();
  $this
    ->assertEqual($num_before, $num_after, "Number of users before ({$num_before}) and after ({$num_after}) is the same");
}