diff --git a/core_search_facets/src/Tests/IntegrationTest.php b/core_search_facets/src/Tests/IntegrationTest.php index 34536d2..dc497cd 100644 --- a/core_search_facets/src/Tests/IntegrationTest.php +++ b/core_search_facets/src/Tests/IntegrationTest.php @@ -120,7 +120,28 @@ class IntegrationTest extends WebTestBase { $this->createFacetBlock($id); + // Assert date facets. $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); + $this->assertLink('March 2016'); + $this->assertLink('April 2016'); + $this->assertResponse(200); + + $this->clickLink('March 2016'); + $this->assertResponse(200); + $this->assertLink('March 8, 2016'); + $this->assertLink('March 9, 2016'); + + $this->clickLink('March 9, 2016'); + $this->assertResponse(200); + $this->assertLink('10 PM'); + $this->assertLink('12 PM'); + + $this->drupalGet('search/node', ['query' => ['keys' => 'test']]); + $this->assertLink('April 2016'); + $this->clickLink('April 2016'); + $this->assertResponse(200); + $this->assertLink('April 1, 2016'); + $this->assertLink('April 2, 2016'); } /** diff --git a/core_search_facets/src/Tests/WebTestBase.php b/core_search_facets/src/Tests/WebTestBase.php index a911de5..450acc8 100644 --- a/core_search_facets/src/Tests/WebTestBase.php +++ b/core_search_facets/src/Tests/WebTestBase.php @@ -59,20 +59,31 @@ abstract class WebTestBase extends SimpletestWebTestBase { $this->drupalCreateContentType(['type' => 'article']); // Adding 10 pages. - for ($i = 0; $i < 10; $i++) { + for ($i = 1; $i <= 9; $i++) { + $created_time = new \DateTime('March '.$i.' 2016 ' . $i . 'PM'); $this->drupalCreateNode(array( 'title' => 'foo bar' . $i, 'body' => 'test page' . $i, 'type' => 'page', + 'created' => $created_time->format('U'), )); } + $created_time = new \DateTime('March 9 2016 11PM'); + $this->drupalCreateNode(array( + 'title' => 'foo bar10', + 'body' => 'test page10', + 'type' => 'page', + 'created' => $created_time->format('U'), + )); // Adding 10 articles. - for ($i = 0; $i < 10; $i++) { + for ($i = 1; $i <= 10; $i++) { + $created_time = new \DateTime('April '.$i.' 2016 ' . $i . 'AM'); $this->drupalCreateNode(array( 'title' => 'foo baz' . $i, 'body' => 'test article' . $i, 'type' => 'article', + 'created' => $created_time->format('U'), )); }