Manually check for queried taxonomy terms when building facets#151
Manually check for queried taxonomy terms when building facets#151kevinfodness merged 8 commits intomainfrom
Conversation
scottnelle
left a comment
There was a problem hiding this comment.
👻 Looks good to me. Good detective work!
|
Would love to see a unit test added for this prior to merge. I can do it if you don't have time @kevinfodness |
|
I can handle. |
|
@mboynes I added a test for facet selection. In order to do that, for compatibility with phpunit in the latest version of WP, I also needed to move phpunit to composer, which I've also done with phpcs. The phpcs ruleset will fail if you run it locally, and we'll need another PR later to fix that up prior to activating the check in #145. |
mboynes
left a comment
There was a problem hiding this comment.
It's SearchPress, dangit!
tests/test-faceting.php
Outdated
| function test_facet_by_taxonomy() { | ||
| // Fake a taxonomy query to WP_Query so the query vars are set properly. | ||
| global $wp_query; | ||
| $wp_query = new WP_Query( |
There was a problem hiding this comment.
nitpicky, but this will trigger a database call... maybe there's no way around that, but if there is, it would be nice to avoid.
There was a problem hiding this comment.
I think that might be possible - I'll give it a try.
There was a problem hiding this comment.
Yep, turns out you can just $wp_query->parse_query( $new_query ) and it works like a charm. I added that and a few other cleanup items that I noticed while setting this up on my new m1 (phpunit polyfills path, trusting phpcs in composer.json, a few other places to use capital_p_dangit)
…es of SearchPress with incorrect capitalization, add PHPUnit Polyfills path constant, trust phpcs in composer.json
Fixes #150