Skip to content
GitLab
Explore
Sign in
project
facets
Compare revisions
b3e1b54646a5084fd3c191b42ba6057079c4f1e2 to 8.x-1.0-alpha1
Hide whitespace changes
Inline
Side-by-side
tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
View file @
7bd666e7
...
...
@@ -57,7 +57,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Test
s
sorting ascending.
*/
public
function
testAscending
()
{
$sorted_results
=
$this
->
processor
->
sortResults
(
$this
->
originalResults
,
'ASC'
);
...
...
@@ -68,7 +68,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Test
s
sorting descending.
*/
public
function
testDescending
()
{
$sorted_results
=
$this
->
processor
->
sortResults
(
$this
->
originalResults
,
'DESC'
);
...
...
tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php
View file @
7bd666e7
...
...
@@ -73,7 +73,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Test
s
no filtering happens.
*/
public
function
testNoFilter
()
{
$facet
=
new
Facet
([],
'facet'
);
...
...
@@ -94,7 +94,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Test
s
no filtering happens.
*/
public
function
testMinEqualsValue
()
{
$facet
=
new
Facet
([],
'facet'
);
...
...
@@ -116,7 +116,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test between minimum and maximum values.
* Test
s
between minimum and maximum values.
*/
public
function
testBetweenMinAndMaxValue
()
{
$facet
=
new
Facet
([],
'facet'
);
...
...
@@ -142,7 +142,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test maximum values.
* Test
s
maximum values.
*/
public
function
testMaxValue
()
{
$facet
=
new
Facet
([],
'facet'
);
...
...
@@ -172,7 +172,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
* Test filtering of results.
* Test
s
filtering of results.
*/
public
function
testFilterResults
()
{
$facet
=
new
Facet
([],
'facet'
);
...
...
tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
View file @
7bd666e7
...
...
@@ -48,7 +48,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Test
s
sorting ascending.
*/
public
function
testAscending
()
{
...
...
@@ -63,7 +63,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Test
s
sorting descending.
*/
public
function
testDescending
()
{
...
...
tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
View file @
7bd666e7
...
...
@@ -52,7 +52,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Test
s
sorting ascending.
*/
public
function
testAscending
()
{
$sorted_results
=
$this
->
processor
->
sortResults
(
$this
->
originalResults
,
'ASC'
);
...
...
@@ -71,7 +71,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Test
s
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.
* Test
s
that sorting uses the display value.
*/
public
function
testUseActualDisplayValue
()
{
$original
=
[
...
...
tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php
View file @
7bd666e7
...
...
@@ -78,19 +78,11 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
* Test no filtering happens.
* Test
s
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.
* Test
s
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.
* Test
s
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.
* Provide
s
multiple data sets for ::testRegexFilter.
*/
public
function
provideRegexTests
()
{
return
[
...
...
tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php
View file @
7bd666e7
...
...
@@ -48,9 +48,8 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
$this
->
processor
=
new
HideNonNarrowingResultProcessor
([],
'hide_non_narrowing_result_processor'
,
[]);
}
/**
* Test filtering of results.
* Test
s
filtering of results.
*/
public
function
testNoFilterResults
()
{
...
...
@@ -70,7 +69,7 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
}
/**
* Test filtering of results.
* Test
s
filtering of results.
*/
public
function
testFilterResults
()
{
...
...
tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
View file @
7bd666e7
...
...
@@ -52,7 +52,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting ascending.
* Test
s
sorting ascending.
*/
public
function
testAscending
()
{
$sorted_results
=
$this
->
processor
->
sortResults
(
$this
->
originalResults
,
'ASC'
);
...
...
@@ -71,7 +71,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
* Test sorting descending.
* Test
s
sorting descending.
*/
public
function
testDescending
()
{
$sorted_results
=
$this
->
processor
->
sortResults
(
$this
->
originalResults
,
'DESC'
);
...
...
tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php
View file @
7bd666e7
...
...
@@ -38,9 +38,8 @@ class UidToUserNameCallbackProcessorTest extends UnitTestCase {
$this
->
createMocks
();
}
/**
* Test that results were correctly changed.
* Test
s
that results were correctly changed.
*/
public
function
testResultsChanged
()
{
$original_results
=
[
...
...
tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php
View file @
7bd666e7
...
...
@@ -36,7 +36,7 @@ class UrlProcessorHandlerTest extends UnitTestCase {
}
/**
* Test that the build method is correctly called.
* Test
s
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'
)
...
...
tests/src/Unit/Plugin/query_type/SearchApiStringTest.php
View file @
7bd666e7
...
...
@@ -20,11 +20,14 @@ use Drupal\Tests\UnitTestCase;
class
SearchApiStringTest
extends
UnitTestCase
{
/**
* Test string query type without executing the query.
* Test
s
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.
* Test
s
string query type without results.
*/
public
function
testEmptyResults
()
{
$query
=
new
SearchApiQuery
([],
'search_api_query'
,
[]);
...
...
tests/src/Unit/Plugin/url_processor/QueryStringTest.php
View file @
7bd666e7
...
...
@@ -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
s
with 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.
* Test
s
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.
* Test
s
that the facet source configuration filter key override works.
*/
public
function
testFacetSourceFilterKeyOverride
()
{
$facet_source
=
new
FacetSource
([
'filter
K
ey'
=>
'ab'
],
'facets_facet_source'
);
$facet_source
=
new
FacetSource
([
'filter
_k
ey'
=>
'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
.
* Set
s up a
container.
*/
protected
function
setContainer
()
{
$router
=
$this
->
getMockBuilder
(
'Drupal\Tests\Core\Routing\TestRouterInterface'
)
...
...
tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
View file @
7bd666e7
...
...
@@ -71,17 +71,17 @@ class CheckboxWidgetTest extends UnitTestCase {
}
/**
* Test widget with default settings.
* Test
s
widget with default settings.
*/
public
function
testDefaultSettings
()
{
$facet
=
new
Facet
([],
'facet'
);
$facet
->
setResults
(
$this
->
originalResults
);
$facet
->
setFieldIdentifier
(
'test_field'
);
$form
S
tate
=
new
FormState
();
$form
S
tate
->
addBuildInfo
(
'args'
,
[
$facet
]);
$form
_s
tate
=
new
FormState
();
$form
_s
tate
->
addBuildInfo
(
'args'
,
[
$facet
]);
$form
=
[];
$built_form
=
$this
->
widget
->
buildForm
(
$form
,
$form
S
tate
);
$built_form
=
$this
->
widget
->
buildForm
(
$form
,
$form
_s
tate
);
$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.
* Test
s
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
]);
$form
S
tate
=
new
FormState
();
$form
S
tate
->
addBuildInfo
(
'args'
,
[
$facet
]);
$form
_s
tate
=
new
FormState
();
$form
_s
tate
->
addBuildInfo
(
'args'
,
[
$facet
]);
$form
=
[];
$built_form
=
$this
->
widget
->
buildForm
(
$form
,
$form
S
tate
);
$built_form
=
$this
->
widget
->
buildForm
(
$form
,
$form
_s
tate
);
$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
,
$form
S
tate
);
$built_form
=
$this
->
widget
->
buildForm
(
$form
,
$form
_s
tate
);
$this
->
assertInternalType
(
'array'
,
$built_form
);
$this
->
assertCount
(
4
,
$built_form
[
'test__field'
][
'#options'
]);
...
...
tests/src/Unit/Plugin/widget/LinksWidgetTest.php
View file @
7bd666e7
...
...
@@ -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.
* Test
s
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.
* Test
s
widget, make sure hiding and showing numbers works.
*/
public
function
testHideNumbers
()
{
$original_results
=
$this
->
originalResults
;
...
...
tests/src/Unit/Processor/ProcessorPluginManagerTest.php
View file @
7bd666e7
...
...
@@ -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
);
}
/**
...
...
tests/src/Unit/QueryType/QueryTypePluginManagerTest.php
View file @
7bd666e7
...
...
@@ -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
);
}
/**
...
...
Prev
1
2
3
4
Next