-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude category taxonomy from root tax check #2299
Changes from 15 commits
fc793be
9e54581
146acea
9af2209
a3dd136
0717ae3
1425d8e
1b2c0a0
f8bb565
e3be127
e44f97c
aba0b3d
e77e32d
41803d4
13a1cb2
b7193f4
8438d25
65517a8
e42661d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
use ElasticPress; | ||
use ElasticPress\Indexables as Indexables; | ||
use function ElasticPressTest\Functions\create_and_sync_term; | ||
|
||
/** | ||
* Test post indexable class | ||
|
@@ -6196,4 +6197,42 @@ public function testPostPrepareDateTerms() { | |
$this->assertArrayHasKey( 'second', $return_prepare_date_terms ); | ||
$this->assertArrayHasKey( 'm', $return_prepare_date_terms ); | ||
} | ||
|
||
/** | ||
* Test when we perform a Tax Query with Id's for category taxonomy they are used instead of a cat slug. | ||
* | ||
* @return void | ||
* @group post | ||
*/ | ||
public function testCatIdTaxQuery() { | ||
$term = Functions\create_and_sync_term( 'test', 'Test category', 'The testing category', 'category' ); | ||
|
||
$args = [ | ||
'post_type' => 'post', | ||
'post_status' => 'publish', | ||
'ep_integrate' => true, | ||
'tax_query' => array( | ||
array( | ||
'taxonomy' => 'category', | ||
'terms' => array( $term ), | ||
'field' => 'term_id', | ||
'operator' => 'in', | ||
) | ||
) | ||
]; | ||
|
||
$query = new \WP_Query( $args ); | ||
|
||
$post = new \ElasticPress\Indexable\Post\Post(); | ||
|
||
$args = $post->format_args( | ||
[ | ||
'cat_name' => 'test', | ||
], | ||
$query | ||
); | ||
|
||
$this->assertContains( $term, $args['post_filter']['bool']['must'][0]['bool']['must'][0]['terms']['terms.category.term_id'] ); | ||
$this->assertNotContains( 'test', $args['post_filter']['bool']['must'][0]['bool']['must'][1]['terms']['terms.category.slug'] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to update the assertion because Maybe we need to check if the array Makes sense? |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PHPUnit is getting an error in this line
Error: Call to a member function index() on bool