Skip to content
......@@ -7,7 +7,7 @@
namespace Drupal\facets\Tests;
use \Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
use Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
/**
* Tests the functionality of the facet source config entity.
......@@ -17,9 +17,21 @@ use \Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
class FacetSourceTest extends FacetWebTestBase {
/**
* Test the facet source editing.
* {@inheritdoc}
*/
public function testFacetSource() {
public static $modules = [
'views',
'search_api',
'search_api_test_backend',
'facets',
'facets_search_api_dependency',
'facets_query_processor',
];
/**
* Tests the facet source editing.
*/
public function testEditFilterKey() {
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
......@@ -29,12 +41,46 @@ class FacetSourceTest extends FacetWebTestBase {
$this->clickLink($this->t('Configure'));
// Test the edit page.
$this->assertField('filterKey');
$this->drupalPostForm(NULL, array('filterKey' => 'fq'), $this->t('Save'));
$edit = array(
'filter_key' => 'fq',
);
$this->assertField('filter_key');
$this->assertField('url_processor');
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$this->assertResponse(200);
// Test that saving worked.
$this->assertField('filterKey');
// Test that saving worked filter_key has the new value.
$this->assertField('filter_key');
$this->assertField('url_processor');
$this->assertRaw('fq');
}
/**
* Tests editing the url processor.
*/
public function testEditUrlProcessor() {
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
// Test the overview.
$this->drupalGet('admin/config/search/facets');
$this->assertLink($this->t('Configure'));
$this->clickLink($this->t('Configure'));
// Test the edit page.
$edit = array(
'url_processor' => 'dummy_query',
);
$this->assertField('filter_key');
$this->assertField('url_processor');
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$this->assertResponse(200);
// Test that saving worked and that the url processor has the new value.
$this->assertField('filter_key');
$this->assertField('url_processor');
$elements = $this->xpath('//input[@id=:id]', [':id' => 'edit-url-processor-dummy-query']);
$this->assertEqual('dummy_query', $elements[0]['value']);
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -11,7 +11,6 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\search_api\Entity\Index;
use Drupal\search_api\Entity\Server;
use Drupal\simpletest\WebTestBase as SimpletestWebTestBase;
use Drupal\search_api\Utility;
/**
* Provides the base class for web tests for Search API.
......@@ -21,15 +20,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
use StringTranslationTrait;
use ExampleContentTrait;
/**
* Exempt from strict schema checking.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = FALSE;
/**
* Modules to enable for this test.
*
......@@ -41,7 +31,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
'search_api',
'search_api_test_backend',
'facets',
'search_api_test_views',
'block',
'facets_search_api_dependency',
];
......@@ -67,13 +56,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
*/
protected $anonymousUser;
/**
* The URL generator.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* A search index ID.
*
......@@ -100,13 +82,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
$this->unauthorizedUser = $this->drupalCreateUser(['access administration pages']);
$this->anonymousUser = $this->drupalCreateUser();
// Get the URL generator.
$this->urlGenerator = $this->container->get('url_generator');
$this->setUpExampleStructure();
\Drupal::getContainer()->get('search_api.index_task_manager')->addItemsAll(Index::load($this->indexId));
}
/**
......@@ -182,6 +157,7 @@ abstract class WebTestBase extends SimpletestWebTestBase {
'datasources' => array($datasource_id),
));
$index->save();
$this->indexId = $index->id();
}
return $index;
......
This diff is collapsed.
<?php
/**
* @file
* Contains Drupal\facets\Processor\UrlProcessorPluginBase.
* Contains Drupal\facets\UrlProcessor\UrlProcessorPluginBase.
*/
namespace Drupal\facets\Processor;
namespace Drupal\facets\UrlProcessor;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\facets\Exception\InvalidProcessorException;
use Drupal\facets\Processor\ProcessorPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
......@@ -56,7 +57,7 @@ abstract class UrlProcessorPluginBase extends ProcessorPluginBase implements Url
$this->request = $request;
if (!isset($configuration['facet'])) {
throw new InvalidProcessorException();
throw new InvalidProcessorException("The url processor doesn't have the required 'facet' in the configuration array.");
}
/** @var \Drupal\facets\FacetInterface $facet */
......
This diff is collapsed.
......@@ -14,7 +14,7 @@ use Drupal\facets\FacetInterface;
interface WidgetInterface {
/**
* Add facet info to the query using the selected query type.
* Adds facet info to the query using the selected query type.
*
* @return mixed
* A boolean
......@@ -33,7 +33,7 @@ interface WidgetInterface {
public function build(FacetInterface $facet);
/**
* Pick the preferred query type for this widget.
* Picks the preferred query type for this widget.
*
* @param string[] $query_types
* An array keyed with query type name and it's plugin class to load.
......
This diff is collapsed.
This diff is collapsed.