You are here

function SearchbyPageAttachReindexTest::testReindexingAutomatic in Search by Page 6

Same name and namespace in other branches
  1. 7 tests/search_by_page.test \SearchbyPageAttachReindexTest::testReindexingAutomatic()

Tests that cycling through attachment reindexing happens correctly.

File

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

Class

SearchbyPageAttachReindexTest
Tests attachment reindexing.

Code

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

  // Set to reindex automatically on normal cycle.
  $this
    ->drupalPost('admin/settings/search_by_page/edit/' . $this->envid2, array(
    'sbp_attach_min_time' => 1,
    'sbp_attach_max_time' => 0,
  ), 'Save configuration');
  cache_clear_all('variables', 'cache');
  variable_init();

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

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

  // In a loop: run cron, and verify each time that the oldest item
  // (or one of them, if there was a tie) 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;
  }
}