SearchPageTest.php in Google Search Appliance 8
File
tests/src/Functional/SearchPageTest.php
View source
<?php
namespace Drupal\Tests\google_appliance\Functional;
use Drupal\google_appliance\Routing\SearchViewRoute;
use Drupal\Core\Url;
class SearchPageTest extends GoogleApplianceFunctionalTestBase {
public function testSearchPage() {
$this
->drupalLogin($this->adminUser);
$settings = [
'hostname' => 'http://www.mygsa.net',
'collection' => 'default_collection',
'frontend' => 'default_frontend',
'timeout' => 10,
'autofilter' => '1',
'query_inspection' => FALSE,
'search_title' => $this
->randomMachineName(16),
'results_per_page' => 16,
];
$this
->drupalGet('admin/config/search/google_appliance/settings');
$this
->submitForm($settings, 'Save configuration');
$assert = $this
->assertSession();
$assert
->pageTextContains('The configuration options have been saved');
$this
->drupalGet('gsearch');
$assert
->statusCodeEquals(200);
$assert
->pageTextContains($settings['search_title']);
$assert
->fieldValueEquals('edit-search-keys', '');
$assert
->pageTextContains('Enter the terms you wish to search for.');
$assert
->pageTextNotContains('Search Results');
$terms = [
'search_keys' => $this
->randomMachineName(8),
];
$this
->submitForm($terms, 'Search');
$this
->assertEquals(Url::fromRoute(SearchViewRoute::ROUTE_NAME, [
'search_query' => $terms['search_keys'],
])
->setAbsolute()
->toString(), $this
->getSession()
->getCurrentUrl());
$assert
->fieldValueEquals('search_keys', $terms['search_keys']);
$assert
->pageTextContains('No Results');
}
}