You are here

public function SearchByPageUsersReindexTest::setUp in Search by Page 8

Overrides SearchByPageTesterTest::setUp

File

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

Class

SearchByPageUsersReindexTest
Tests when users are reindexed.

Namespace

Drupal\Tests\search_by_page\Functional

Code

public function setUp() {
  parent::setUp('search', 'search_by_page', 'search_by_page_users', 'search_by_page_test', 'dblog');
  $this
    ->setUpEnvironments();

  // Set up five users for searching
  for ($i = 0; $i < 5; $i++) {
    $acct = $this
      ->drupalCreateUser(array(
      'access content',
    ));
    $this->users[] = $acct;
    $this->roles[$this
      ->getNewRoleID($acct)] = 1;
  }

  // Set up a user that can see user profiles, to use when indexing.
  $this->indexuser = $this
    ->drupalCreateUser(array(
    'access user profiles',
  ));
  $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->envinfo2),
    'administer site configuration',
    'administer users',
    'administer permissions',
    'view test private content',
    'access user profiles',
    'access site reports',
  ));
  $this
    ->drupalLogin($this->superuser);

  // Make sure all our test users are indexed.
  $edit = array(
    'search_by_page_users_role' => $this
      ->getNewRoleID($this->indexuser),
    'button_label' => t('Search pages'),
  );
  foreach (array_keys($this->roles) as $rid) {
    $edit['search_by_page_users_roles_indexed[' . $rid . ']'] = TRUE;
  }
  $this
    ->drupalPostForm('admin/config/search/search_by_page/edit/' . $this->envid2, $edit, 'Save configuration');
  drupal_flush_all_caches();
  variable_initialize();
  $this
    ->doCronrun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
  $this
    ->drupalLogout();
}