Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
facets
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
8
Merge Requests
8
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
facets
Commits
27d088d7
Commit
27d088d7
authored
Jun 09, 2018
by
borisson_
Committed by
borisson_
Jun 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2949260
by borisson_: Show active facets even when "Hide facet with 1 result" is selected
parent
3b27b114
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
src/Plugin/facets/processor/HideOnlyOneItemProcessor.php
src/Plugin/facets/processor/HideOnlyOneItemProcessor.php
+1
-1
tests/src/Functional/ProcessorIntegrationTest.php
tests/src/Functional/ProcessorIntegrationTest.php
+7
-3
tests/src/Unit/Plugin/processor/HideOnlyOneItemProcessorTest.php
...rc/Unit/Plugin/processor/HideOnlyOneItemProcessorTest.php
+19
-0
No files found.
src/Plugin/facets/processor/HideOnlyOneItemProcessor.php
View file @
27d088d7
...
...
@@ -24,7 +24,7 @@ class HideOnlyOneItemProcessor extends ProcessorPluginBase implements BuildProce
* {@inheritdoc}
*/
public
function
build
(
FacetInterface
$facet
,
array
$results
)
{
if
(
count
(
$results
)
===
1
)
{
if
(
count
(
$results
)
===
1
&&
!
$results
[
0
]
->
isActive
()
)
{
return
[];
}
...
...
tests/src/Functional/ProcessorIntegrationTest.php
View file @
27d088d7
...
...
@@ -768,6 +768,12 @@ class ProcessorIntegrationTest extends FacetsTestBase {
public
function
testHideOnlyOneItemProcessor
()
{
$entity_test_storage
=
\
Drupal
::
entityTypeManager
()
->
getStorage
(
'entity_test_mulrev_changed'
);
// Load all items and delete them.
$all
=
$entity_test_storage
->
loadMultiple
();
foreach
(
$all
as
$item
)
{
$item
->
delete
();
}
$entity_test_storage
->
create
([
'name'
=>
'baz baz'
,
'body'
=>
'foo test'
,
...
...
@@ -775,7 +781,6 @@ class ProcessorIntegrationTest extends FacetsTestBase {
'keywords'
=>
[
'kiwi'
],
'category'
=>
'article_category'
,
])
->
save
();
$this
->
indexItems
(
$this
->
indexId
);
$facet_name
=
'Drupalcon Vienna'
;
...
...
@@ -790,8 +795,7 @@ class ProcessorIntegrationTest extends FacetsTestBase {
$this
->
drupalPostForm
(
$this
->
editForm
,
$form
,
'Save'
);
$this
->
drupalGet
(
'search-api-test-fulltext'
);
$this
->
assertFacetBlocksAppear
();
$this
->
clickLink
(
'kiwi'
);
$this
->
assertSession
()
->
pageTextContains
(
' Displaying 1 search results'
);
$this
->
assertNoFacetBlocksAppear
();
}
...
...
tests/src/Unit/Plugin/processor/HideOnlyOneItemProcessorTest.php
View file @
27d088d7
...
...
@@ -33,6 +33,25 @@ class HideOnlyOneItemProcessorTest extends UnitTestCase {
$this
->
assertCount
(
0
,
$processed_results
);
}
/**
* Tests with one result that is already active.
*
* @covers ::build
*/
public
function
testWithOneActiveResult
()
{
$processor
=
new
HideOnlyOneItemProcessor
([],
'hide_only_one_item'
,
[]);
$facet
=
new
Facet
([],
'facets_facet'
);
$results
=
[
new
Result
(
$facet
,
'1'
,
1
,
1
),
];
$results
[
0
]
->
setActiveState
(
TRUE
);
$facet
=
$this
->
getMockBuilder
(
Facet
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$processed_results
=
$processor
->
build
(
$facet
,
$results
);
$this
->
assertCount
(
1
,
$processed_results
);
}
/**
* Tests with one result.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment