public function SearchByPageTesterTest::setUpEnvironments in Search by Page 8
Creates two environments for Search by Page.
19 calls to SearchByPageTesterTest::setUpEnvironments()
- SearchbyPageAttach2Test::setUp in tests/
src/ Functional/ search_by_page.test - SearchbyPageAttachNotReadable::setUp in tests/
src/ Functional/ search_by_page.test - SearchbyPageAttachReindexTest::setUp in tests/
src/ Functional/ search_by_page.test - SearchByPageAttachTest::setUp in tests/
src/ Functional/ search_by_page.test - SearchByPageEnvironmentTest::setUp in tests/
src/ Functional/ SearchByPageEnvironmentTest.php
File
- tests/
src/ Functional/ SearchByPageTesterTest.php, line 39 - General Functional Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageTesterTest
- Base class for testing Search by Page.
Namespace
Drupal\Tests\search_by_page\FunctionalCode
public function setUpEnvironments() {
$user = $this
->createUser([
'administer search by page',
'access administration pages',
'administer site configuration',
'administer search',
]);
$this
->drupalLogin($user);
// Content access permissions always need to be rebuilt for some reason.
node_access_rebuild();
// Verify this module is active in Search.
$active = \Drupal::state()
->get('search_active_modules', [
'node',
'user',
]);
$this
->assertTrue(in_array('search_by_page', $active));
// Clear out any existing search environments that may have been defined.
$envs = search_by_page_list_environments();
foreach ($envs as $env) {
\Drupal::moduleHandler()
->invokeAll('search_by_page_delete_environment', $env);
}
// Define two new environments. They should have ID numbers 1 and 2.
$this->envinfo1 = [
'environment_name' => 'env1',
'set_as_default' => 1,
'page_title' => t('Search page 1 title'),
'block_title' => t('Search block 1 title'),
'field_label' => t('Search field 1 label'),
'button_label' => t('Search button 1 label'),
'page_path' => 'search_path_1',
'exclude_tags' => 'tagtoexclude',
];
$this
->drupalPostForm('admin/config/search/search_by_page/add', $this->envinfo1, 'Save configuration');
$this->envid1 = 1;
$this->envinfo2 = [
'environment_name' => 'env2',
'set_as_default' => 2,
'page_title' => t('Search page 2 title'),
'block_title' => t('Search block 2 title'),
'field_label' => t('Search field 2 label'),
'button_label' => t('Search button 2 label'),
'page_path' => 'search_path_2',
];
$this
->drupalPostForm('admin/config/search/search_by_page/add', $this->envinfo2, 'Save configuration');
$this->envid2 = 2;
// Reset the permissions cache.
$this
->checkPermissions([]);
$this
->drupalLogout();
}