Skip to content
......@@ -57,7 +57,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
......@@ -68,7 +68,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
......
......@@ -73,7 +73,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Tests no filtering happens.
*/
public function testNoFilter() {
$facet = new Facet([], 'facet');
......@@ -94,7 +94,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Tests no filtering happens.
*/
public function testMinEqualsValue() {
$facet = new Facet([], 'facet');
......@@ -116,7 +116,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test between minimum and maximum values.
* Tests between minimum and maximum values.
*/
public function testBetweenMinAndMaxValue() {
$facet = new Facet([], 'facet');
......@@ -142,7 +142,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test maximum values.
* Tests maximum values.
*/
public function testMaxValue() {
$facet = new Facet([], 'facet');
......@@ -172,7 +172,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test filtering of results.
* Tests filtering of results.
*/
public function testFilterResults() {
$facet = new Facet([], 'facet');
......
......@@ -48,7 +48,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Tests sorting ascending.
*/
public function testAscending() {
......@@ -63,7 +63,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Tests sorting descending.
*/
public function testDescending() {
......
......@@ -52,7 +52,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
......@@ -71,7 +71,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
......@@ -90,7 +90,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test that sorting uses the display value.
* Tests that sorting uses the display value.
*/
public function testUseActualDisplayValue() {
$original = [
......
......@@ -78,19 +78,11 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Tests no filtering happens.
*/
public function testNoFilter() {
$facet = new Facet([], 'facet');
$facet->setResults($this->originalResults);
$facet->setOption('processors', [
'exclude_specified_items' => [
'settings' => [
'exclude' => 'alpaca',
'regex' => 0,
],
],
]);
$facet->addProcessor([
'processor_id' => 'exclude_specified_items',
'weights' => [],
......@@ -109,19 +101,11 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
* Test filtering happens for string filter.
* Tests filtering happens for string filter.
*/
public function testStringFilter() {
$facet = new Facet([], 'facet');
$facet->setResults($this->originalResults);
$facet->setOption('processors', [
'exclude_specified_items' => [
'settings' => [
'exclude' => 'llama',
'regex' => 0,
],
],
]);
$facet->addProcessor([
'processor_id' => 'exclude_specified_items',
'weights' => [],
......@@ -144,21 +128,13 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
* Test filtering happens for regex filter.
* Tests filtering happens for regex filter.
*
* @dataProvider provideRegexTests
*/
public function testRegexFilter($regex, $expected_results) {
$facet = new Facet([], 'facet');
$facet->setResults($this->originalResults);
$facet->setOption('processors', [
'exclude_specified_items' => [
'settings' => [
'exclude' => $regex,
'regex' => 1,
],
],
]);
$facet->addProcessor([
'processor_id' => 'exclude_specified_items',
'weights' => [],
......@@ -181,7 +157,7 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
* Provide multiple data sets for ::testRegexFilter.
* Provides multiple data sets for ::testRegexFilter.
*/
public function provideRegexTests() {
return [
......
......@@ -48,9 +48,8 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
$this->processor = new HideNonNarrowingResultProcessor([], 'hide_non_narrowing_result_processor', []);
}
/**
* Test filtering of results.
* Tests filtering of results.
*/
public function testNoFilterResults() {
......@@ -70,7 +69,7 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
}
/**
* Test filtering of results.
* Tests filtering of results.
*/
public function testFilterResults() {
......
......@@ -52,7 +52,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
......@@ -71,7 +71,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
......
......@@ -38,9 +38,8 @@ class UidToUserNameCallbackProcessorTest extends UnitTestCase {
$this->createMocks();
}
/**
* Test that results were correctly changed.
* Tests that results were correctly changed.
*/
public function testResultsChanged() {
$original_results = [
......
......@@ -36,7 +36,7 @@ class UrlProcessorHandlerTest extends UnitTestCase {
}
/**
* Test that the build method is correctly called.
* Tests that the build method is correctly called.
*/
public function testBuild() {
$facet = new Facet(['id' => '_test'], 'facets_facet');
......@@ -48,7 +48,7 @@ class UrlProcessorHandlerTest extends UnitTestCase {
}
/**
* Helper function to create a correct container.
* Sets up a container.
*/
protected function createContainer() {
$url_processor = $this->getMockBuilder('\Drupal\facets\UrlProcessor\UrlProcessorInterface')
......
......@@ -20,11 +20,14 @@ use Drupal\Tests\UnitTestCase;
class SearchApiStringTest extends UnitTestCase {
/**
* Test string query type without executing the query.
* Tests string query type without executing the query.
*/
public function testQueryType() {
$query = new SearchApiQuery([], 'search_api_query', []);
$facet = new Facet([], 'facets_facet');
$facet = new Facet(
['query_operator' => 'AND'],
'facets_facet'
);
$original_results = [
['count' => 3, 'filter' => 'badger'],
......@@ -57,7 +60,7 @@ class SearchApiStringTest extends UnitTestCase {
}
/**
* Test string query type without results.
* Tests string query type without results.
*/
public function testEmptyResults() {
$query = new SearchApiQuery([], 'search_api_query', []);
......
......@@ -63,7 +63,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Basic test with one active item.
* Tests with one active item.
*/
public function testSetSingleActiveItem() {
$facet = new Facet([], 'facet');
......@@ -81,7 +81,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Basic test with multiple active items.
* Tests with multiple active items.
*/
public function testSetMultipleActiveItems() {
$facet = new Facet([], 'facet');
......@@ -99,7 +99,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Basic test with an empty build.
* Tests with an empty build.
*/
public function testEmptyBuild() {
$facet = new Facet([], 'facet');
......@@ -115,7 +115,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Test with default build.
* Test swith default build.
*/
public function testBuild() {
$facet = new Facet([], 'facet');
......@@ -137,7 +137,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Test with an active item already from url.
* Tests with an active item already from url.
*/
public function testBuildWithActiveItem() {
$facet = new Facet([], 'facet');
......@@ -167,10 +167,10 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Test that the facet source configuration filter key override works.
* Tests that the facet source configuration filter key override works.
*/
public function testFacetSourceFilterKeyOverride() {
$facet_source = new FacetSource(['filterKey' => 'ab'], 'facets_facet_source');
$facet_source = new FacetSource(['filter_key' => 'ab'], 'facets_facet_source');
// Override the container with the new facet source.
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
......@@ -208,7 +208,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
* Set the container for use in unit tests.
* Sets up a container.
*/
protected function setContainer() {
$router = $this->getMockBuilder('Drupal\Tests\Core\Routing\TestRouterInterface')
......
......@@ -71,17 +71,17 @@ class CheckboxWidgetTest extends UnitTestCase {
}
/**
* Test widget with default settings.
* Tests widget with default settings.
*/
public function testDefaultSettings() {
$facet = new Facet([], 'facet');
$facet->setResults($this->originalResults);
$facet->setFieldIdentifier('test_field');
$formState = new FormState();
$formState->addBuildInfo('args', [$facet]);
$form_state = new FormState();
$form_state->addBuildInfo('args', [$facet]);
$form = [];
$built_form = $this->widget->buildForm($form, $formState);
$built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test_field']['#options']);
......@@ -91,7 +91,7 @@ class CheckboxWidgetTest extends UnitTestCase {
'llama' => 'Llama',
'badger' => 'Badger',
'duck' => 'Duck',
'alpaca' => 'Alpaca'
'alpaca' => 'Alpaca',
];
foreach ($expected_links as $index => $value) {
$this->assertEquals($value, $built_form['test_field']['#options'][$index]);
......@@ -99,7 +99,7 @@ class CheckboxWidgetTest extends UnitTestCase {
}
/**
* Test widget, make sure hiding and showing numbers works.
* Tests widget, make sure hiding and showing numbers works.
*/
public function testHideNumbers() {
$original_results = $this->originalResults;
......@@ -110,10 +110,10 @@ class CheckboxWidgetTest extends UnitTestCase {
$facet->setFieldIdentifier('test__field');
$facet->setWidgetConfigs(['show_numbers' => 0]);
$formState = new FormState();
$formState->addBuildInfo('args', [$facet]);
$form_state = new FormState();
$form_state->addBuildInfo('args', [$facet]);
$form = [];
$built_form = $this->widget->buildForm($form, $formState);
$built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test__field']['#options']);
......@@ -121,7 +121,7 @@ class CheckboxWidgetTest extends UnitTestCase {
'llama' => 'Llama',
'badger' => 'Badger',
'duck' => 'Duck',
'alpaca' => 'Alpaca'
'alpaca' => 'Alpaca',
];
foreach ($expected_links as $index => $value) {
$this->assertEquals($value, $built_form['test__field']['#options'][$index]);
......@@ -131,7 +131,7 @@ class CheckboxWidgetTest extends UnitTestCase {
// between those settings works.
$facet->setWidgetConfigs(['show_numbers' => 1]);
$built_form = $this->widget->buildForm($form, $formState);
$built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test__field']['#options']);
......
......@@ -11,7 +11,6 @@ use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\widget\LinksWidget;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Unit test for widget.
......@@ -57,7 +56,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
* Test widget.
* Tests widget without filters.
*/
public function testNoFilterResults() {
$facet = new Facet([], 'facet');
......@@ -77,30 +76,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
* Test widget.
*/
public function testHideEmptyCount() {
$original_results = $this->originalResults;
$original_results[1] = new Result('badger', 'Badger', 0);
$facet = new Facet([], 'facet');
$facet->setResults($original_results);
$facet->setWidgetConfigs(['show_numbers' => 1]);
$output = $this->widget->build($facet);
$this->assertInternalType('array', $output);
$this->assertCount(3, $output['#items']);
$expected_links = ['Llama (10)', 'Duck (15)', 'Alpaca (9)'];
foreach ($expected_links as $index => $value) {
$this->assertInstanceOf('\Drupal\Core\Link', $output['#items'][$index]);
$this->assertEquals($value, $output['#items'][$index]->getText());
}
}
/**
* Test widget.
* Test widget with 2 active items.
*/
public function testActiveItems() {
$original_results = $this->originalResults;
......@@ -129,7 +105,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
* Test widget, make sure hiding and showing numbers works.
* Tests widget, make sure hiding and showing numbers works.
*/
public function testHideNumbers() {
$original_results = $this->originalResults;
......
......@@ -97,7 +97,8 @@ class ProcessorPluginManagerTest extends UnitTestCase {
*/
public function testConstruct() {
$namespaces = new ArrayObject();
$this->sut = new ProcessorPluginManager($namespaces, $this->cache, $this->moduleHandler, $this->translator);
$sut = new ProcessorPluginManager($namespaces, $this->cache, $this->moduleHandler, $this->translator);
$this->assertInstanceOf('\Drupal\facets\Processor\ProcessorPluginManager', $sut);
}
/**
......
......@@ -86,7 +86,8 @@ class QueryTypePluginManagerTest extends UnitTestCase {
*/
public function testConstruct() {
$namespaces = new ArrayObject();
$this->sut = new QueryTypePluginManager($namespaces, $this->cache, $this->moduleHandler);
$sut = new QueryTypePluginManager($namespaces, $this->cache, $this->moduleHandler);
$this->assertInstanceOf('\Drupal\facets\QueryType\QueryTypePluginManager', $sut);
}
/**
......