Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
facets-3422013
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
facets-3422013
Commits
f48a9c35
Commit
f48a9c35
authored
8 years ago
by
José Manuel Rodríguez Vélez
Committed by
Joris Vercammen
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2696643
by marthinal: Updated date facet for core search
parent
9cb3a2aa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
+2
-0
2 additions, 0 deletions
.../Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
core_search_facets/src/Tests/IntegrationTest.php
+35
-2
35 additions, 2 deletions
core_search_facets/src/Tests/IntegrationTest.php
with
37 additions
and
2 deletions
core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
+
2
−
0
View file @
f48a9c35
...
...
@@ -154,6 +154,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
break
;
case
'created'
:
case
'changed'
:
$query_types
[
'string'
]
=
'core_node_search_date'
;
break
;
...
...
@@ -236,6 +237,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
'uid'
=>
$this
->
t
(
'Author'
),
'langcode'
=>
$this
->
t
(
'Language'
),
'created'
=>
$this
->
t
(
'Post date'
),
'changed'
=>
$this
->
t
(
'Updated date'
),
];
}
...
...
This diff is collapsed.
Click to expand it.
core_search_facets/src/Tests/IntegrationTest.php
+
35
−
2
View file @
f48a9c35
...
...
@@ -3,6 +3,7 @@
namespace
Drupal\core_search_facets\Tests
;
use
Drupal\facets\Tests\ExampleContentTrait
;
use
Drupal\node\Entity\Node
;
/**
* Tests the admin UI with the core search facet source.
...
...
@@ -100,9 +101,9 @@ class IntegrationTest extends WebTestBase {
}
/**
* Tests the
date integration
.
* Tests the
"Post date" facets
.
*/
public
function
testDate
()
{
public
function
test
Post
Date
()
{
$facet_name
=
'Tardigrade'
;
$facet_id
=
'tardigrade'
;
...
...
@@ -135,6 +136,38 @@ class IntegrationTest extends WebTestBase {
$this
->
assertLink
(
'April 2, 2016 (1)'
);
}
/**
* Tests the "Updated date" facets.
*/
public
function
testUpdatedDate
()
{
$facet_name
=
'Tardigrade'
;
$facet_id
=
'tardigrade'
;
$this
->
addFacet
(
$facet_id
,
$facet_name
,
'changed'
);
$this
->
createFacetBlock
(
$facet_id
);
$this
->
setShowAmountOfResults
(
$facet_id
,
TRUE
);
// Update the changed date. The nodes were created on February/March 2016
// and the changed date is December 2016.
$node
=
Node
::
load
(
1
);
$changed_date
=
new
\DateTime
(
'December 3 2016 1PM'
);
$node
->
changed
=
$changed_date
->
format
(
'U'
);
$node
->
save
();
// Index the content.
\Drupal
::
service
(
'plugin.manager.search'
)
->
createInstance
(
'node_search'
)
->
updateIndex
();
search_update_totals
();
$this
->
drupalGet
(
'search/node'
,
[
'query'
=>
[
'keys'
=>
'test'
]]);
$this
->
assertLink
(
'December 2016 (1)'
);
$this
->
clickLink
(
'December 2016 (1)'
);
$this
->
assertResponse
(
200
);
$this
->
assertLink
(
'December 3, 2016 (1)'
);
$this
->
clickLink
(
'December 3, 2016 (1)'
);
$this
->
assertResponse
(
200
);
}
/**
* Tests for CRUD operations.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment