You are here

public function SearchbyPageAttach2Test::setUp in Search by Page 8

Overrides SearchByPageAttachTest::setUp

File

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

Class

SearchbyPageAttach2Test
Functionality test 2 for Search by Page Attachments.

Namespace

Drupal\Tests\search_by_page\Functional

Code

public function setUp() {
  BrowserTestBase::setUp('search', 'search_by_page_test', 'search_by_page_attach', 'file', 'search_files', 'dblog', 'search_by_page');
  $this
    ->setUpEnvironments();
  $this
    ->setUpUsers($this->envinfo1);
  $this
    ->setUpTypes();
  $this
    ->makeContent();

  // Set up so "search_by_page_indexed" node attachments are searchable and
  // "search_by_page_hidden" attachments are not. Also make it so both listed and
  // unlisted files are searchable (functionality test 1 did only listed
  // files).
  // NOTE: When posting to a page with checkboxes, it is VITAL to pass in
  // FALSE rather than 0 for the value, if you want to unset the checkbox!
  $this
    ->drupalPostForm('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'search_by_page_attach_node_types[]' => 'search_by_page_indexed',
    'search_by_page_attach_field_types[]' => 'field_myfile',
    'search_by_page_attach_only_listed' => FALSE,
    'search_by_page_attach_prepend_node_title' => FALSE,
    'search_by_page_attach_title_sep' => " bush ",
    'search_by_page_attach_use_description' => FALSE,
    'search_by_page_attach_role' => $this
      ->getNewRoleID($this->superuser),
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  \Drupal::service('cache.bootstrap')
    ->invalidateAll();
  variable_initialize();
  $this
    ->assertEqual(search_by_page_setting_get('search_by_page_attach_only_listed', $this->envid1, 0), 0, 'Search only listed files is set to FALSE');
  $this
    ->doCronRun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
}