You are here

public function SearchByPageExtraUsersTest::setUp in Search by Page 8

Overrides SearchByPageTesterTest::setUp

File

tests/src/Functional/search_by_page.test, line 620
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.

Namespace

Drupal\Tests\search_by_page\Functional

Code

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

  // Set up super-user.
  $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->envinfo1),
    'administer site configuration',
    'administer users',
    'administer permissions',
    'view test private content',
    'access site reports',
    'access comments',
    'skip comment approval',
    'administer comments',
  ));
  $this
    ->drupalLogin($this->superuser);

  // Set up so "search_by_page_indexed" nodes are searchable.
  // Index them with the super-user.
  $this
    ->drupalPostForm('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'search_by_page_nodes_types_indexed[search_by_page_indexed]' => TRUE,
    'search_by_page_nodes_display_type' => 'excerpts',
    'search_by_page_nodes_role' => $this
      ->getNewRoleID($this->superuser),
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  \Drupal::service('cache.bootstrap')
    ->invalidateAll();
  variable_initialize();

  // Create 5 nodes with the same content.
  $info = array(
    'body' => array(
      self::LANGUAGE_NONE_ => array(
        array(
          'value' => 'blah',
        ),
      ),
    ),
    'type' => 'search_by_page_indexed',
    'language' => self::LANGUAGE_NONE_,
    'title' => 'blah',
    'test_private' => FALSE,
  );
  $this->nodes = array();
  for ($i = 0; $i < 5; $i++) {
    $this->nodes[] = $this
      ->drupalCreateNode($info);
  }

  // Run cron to index these nodes.
  $this
    ->doCronrun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
  $this
    ->drupalLogout();
}