Skip to content
......@@ -45,7 +45,7 @@ class Result implements ResultInterface {
protected $active = FALSE;
/**
* Construct a new instance of the value object.
* Constructs a new result value object.
*
* @param mixed $raw_value
* The raw value.
......
......@@ -15,7 +15,7 @@ use Drupal\Core\Url;
interface ResultInterface {
/**
* Get the raw value as present in the index.
* Returns the raw value as present in the index.
*
* @return string
* The raw value of the result.
......@@ -23,7 +23,7 @@ interface ResultInterface {
public function getRawValue();
/**
* Get the display value as present in the index.
* Returns the display value as present in the index.
*
* @return string
* The formatted value of the result.
......@@ -31,7 +31,7 @@ interface ResultInterface {
public function getDisplayValue();
/**
* Get the count for the result.
* Returns the count for the result.
*
* @return mixed
* The amount of items for the result.
......@@ -39,7 +39,7 @@ interface ResultInterface {
public function getCount();
/**
* Get the url.
* Returns the url.
*
* @return \Drupal\Core\Url
* The url of the search page with the facet url appended.
......@@ -47,7 +47,7 @@ interface ResultInterface {
public function getUrl();
/**
* Set the url.
* Sets the url.
*
* @param \Drupal\Core\Url $url
* The url of the search page with the facet url appended.
......@@ -55,7 +55,7 @@ interface ResultInterface {
public function setUrl(Url $url);
/**
* Indicate that the value is active (selected).
* Indicates that the value is active (selected).
*
* @param bool $active
* A boolean indicating the active state.
......@@ -71,7 +71,7 @@ interface ResultInterface {
public function isActive();
/**
* Override the display value of a result.
* Overrides the display value of a result.
*
* @param string $display_value
* Override display value.
......
<?php
/**
* @file
* Contains \Drupal\facets\Tests\ExampleContentTrait.
*/
namespace Drupal\facets\Tests;
use Drupal\search_api\Entity\Index;
/**
* Contains helpers to create data that can be used by tests.
*/
trait ExampleContentTrait {
/**
* The generated test entities, keyed by ID.
*
* @var \Drupal\entity_test\Entity\EntityTest[]
*/
protected $entities = array();
/**
* Sets up the necessary bundles on the test entity type.
*/
protected function setUpExampleStructure() {
entity_test_create_bundle('item');
entity_test_create_bundle('article');
}
/**
* Creates several test entities.
*/
protected function insertExampleContent() {
$count = \Drupal::entityQuery('entity_test')->count()->execute();
$entity_test_storage = \Drupal::entityTypeManager()
->getStorage('entity_test');
$this->entities[1] = $entity_test_storage->create(array(
'name' => 'foo bar baz',
'body' => 'test test',
'type' => 'item',
'keywords' => array('orange'),
'category' => 'item_category',
));
$this->entities[1]->save();
$this->entities[2] = $entity_test_storage->create(array(
'name' => 'foo test',
'body' => 'bar test',
'type' => 'item',
'keywords' => array('orange', 'apple', 'grape'),
'category' => 'item_category',
));
$this->entities[2]->save();
$this->entities[3] = $entity_test_storage->create(array(
'name' => 'bar',
'body' => 'test foobar',
'type' => 'item',
));
$this->entities[3]->save();
$this->entities[4] = $entity_test_storage->create(array(
'name' => 'foo baz',
'body' => 'test test test',
'type' => 'article',
'keywords' => array('apple', 'strawberry', 'grape'),
'category' => 'article_category',
));
$this->entities[4]->save();
$this->entities[5] = $entity_test_storage->create(array(
'name' => 'bar baz',
'body' => 'foo',
'type' => 'article',
'keywords' => array('orange', 'strawberry', 'grape', 'banana'),
'category' => 'article_category',
));
$this->entities[5]->save();
$count = \Drupal::entityQuery('entity_test')->count()->execute() - $count;
$this->assertEqual($count, 5, "$count items inserted.");
}
/**
* Indexes all (unindexed) items on the specified index.
*
* @param string $index_id
* The ID of the index on which items should be indexed.
*
* @return int
* The number of successfully indexed items.
*/
protected function indexItems($index_id) {
/** @var \Drupal\search_api\IndexInterface $index */
$index = Index::load($index_id);
return $index->indexItems();
}
}
<?php
/**
* @file
* Tests Facets' FacetManager implementation.
*/
namespace Drupal\facets\Tests;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\simpletest\WebTestBase;
/**
* @coversDefaultClass Drupal\facets\Tests\FacetManager
* @group facets
*/
class FacetManagerTest extends WebTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('facets');
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
}
/**
* A mocked test, to make sure the test runner doesn't crash.
*/
public function testMock() {
$this->verbose("We need to have at least one test method in a test or otherwise all tests fail.");
}
}
<?php
/**
* @file
* Contains \Drupal\facets\Tests\FacetSourceTest.
*/
namespace Drupal\facets\Tests;
use Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
/**
* Tests the functionality of the facet source config entity.
*
* @group facets
*/
class FacetSourceTest extends FacetWebTestBase {
/**
* {@inheritdoc}
*/
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);
// 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(
'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 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.
This diff is collapsed.
This diff is collapsed.
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.
......
name: 'Facets query processor'
type: module
description: 'Facets query processor'
package: 'Search'
core: 8.x
hidden: true
This diff is collapsed.