FacetSourceTest.php in Facets 8
File
tests/src/Functional/FacetSourceTest.php
View source
<?php
namespace Drupal\Tests\facets\Functional;
class FacetSourceTest extends FacetsTestBase {
public static $modules = [
'views',
'search_api',
'facets',
'facets_search_api_dependency',
'facets_query_processor',
];
public function setUp() {
parent::setUp();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/search/facets');
$this
->assertSession()
->linkExists('Configure');
$this
->clickLink('Configure');
}
public function testEditFilterKey() {
$edit = [
'filter_key' => 'fq',
];
$this
->assertSession()
->fieldExists('filter_key');
$this
->assertSession()
->fieldExists('url_processor');
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->addressEquals('admin/config/search/facets');
$this
->assertSession()
->pageTextContains('Facet source search_api:views_block__search_api_test_view__block_1 has been saved.');
$this
->clickLink('Configure');
$this
->assertSession()
->fieldExists('filter_key');
$this
->assertSession()
->fieldExists('url_processor');
$this
->assertSession()
->responseContains('fq');
}
public function testEditUrlProcessor() {
$edit = [
'url_processor' => 'dummy_query',
];
$this
->assertSession()
->fieldExists('filter_key');
$this
->assertSession()
->fieldExists('url_processor');
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->addressEquals('admin/config/search/facets');
$this
->assertSession()
->pageTextContains('Facet source search_api:views_block__search_api_test_view__block_1 has been saved.');
$this
->clickLink('Configure');
$this
->assertSession()
->fieldExists('filter_key');
$this
->assertSession()
->fieldExists('url_processor');
$elements = $this
->xpath('//input[@id=:id]', [
':id' => 'edit-url-processor-dummy-query',
]);
$this
->assertEquals('dummy_query', $elements[0]
->getValue());
}
public function testEditBreadcrumbSettings() {
$this
->assertSession()
->fieldExists('breadcrumb[active]');
$this
->assertSession()
->fieldExists('breadcrumb[group]');
$this
->assertSession()
->checkboxNotChecked('breadcrumb[group]');
$this
->assertSession()
->checkboxNotChecked('breadcrumb[active]');
$edit = [
'breadcrumb[active]' => TRUE,
'breadcrumb[group]' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->addressEquals('admin/config/search/facets');
$this
->assertSession()
->pageTextContains('Facet source search_api:views_block__search_api_test_view__block_1 has been saved.');
$this
->clickLink('Configure');
$this
->assertSession()
->checkboxChecked('breadcrumb[group]');
$this
->assertSession()
->checkboxChecked('breadcrumb[active]');
}
}