-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2229 from 10up/fix/facets-pagination
Fix/facets pagination
- Loading branch information
Showing
2 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Test facet feature | ||
* | ||
* @package elasticpress | ||
*/ | ||
|
||
namespace ElasticPressTest; | ||
|
||
use ElasticPress\Features as Features; | ||
|
||
/** | ||
* Facet test class | ||
*/ | ||
class TestFacets extends BaseTestCase { | ||
|
||
/** | ||
* Setup each test. | ||
* | ||
* @since 3.6.0 | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* Clean up after each test. | ||
* | ||
* @since 3.6.0 | ||
*/ | ||
public function tearDown() { | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* Test build query URL | ||
* | ||
* @since 3.6.0 | ||
* @group facets | ||
* | ||
*/ | ||
public function testBuildQueryUrl() { | ||
$facet_feature = Features::factory()->get_registered_feature( 'facets' ); | ||
|
||
$filters = [ | ||
'taxonomies' => [ | ||
'category' => [ | ||
'terms' => [ | ||
'augue' => 1 | ||
] | ||
] | ||
] | ||
]; | ||
|
||
$this->assertEquals( '/?filter_category=augue', $facet_feature->build_query_url( $filters ) ); | ||
|
||
set_query_var( 's', 'dolor' ); | ||
$this->assertEquals( '/?s=dolor&filter_category=augue', $facet_feature->build_query_url( $filters ) ); | ||
|
||
set_query_var( 's', '' ); | ||
$filters = [ | ||
'taxonomies' => [ | ||
'category' => [ | ||
'terms' => [ | ||
'augue' => 1, | ||
'consectetur' => 1 | ||
] | ||
] | ||
] | ||
]; | ||
|
||
$this->assertEquals( '/?filter_category=augue,consectetur', $facet_feature->build_query_url( $filters ) ); | ||
|
||
$_SERVER['REQUEST_URI'] = 'test/page/1'; | ||
|
||
set_query_var( 's', 'dolor' ); | ||
$this->assertEquals( 'test/?s=dolor&filter_category=augue,consectetur', $facet_feature->build_query_url( $filters ) ); | ||
|
||
} | ||
|
||
} |