diff --git a/Tests/Integration/FilterWPQueryTest.php b/Tests/Integration/FilterWPQueryTest.php index cd5edbd..a9e86d6 100755 --- a/Tests/Integration/FilterWPQueryTest.php +++ b/Tests/Integration/FilterWPQueryTest.php @@ -28,7 +28,7 @@ public function testAddFilter() //Make sure addFilter() had the right effect -- it was added with priority 10 $this->assertEquals( FilterWPQuery::getFilterPriority(), - has_filter('posts_pre_query', [FilterWPQuery::class, 'callback']) + has_filter('posts_pre_query', [FilterWPQuery::class, 'filterPreQuery']) ); } @@ -44,7 +44,7 @@ public function testFilterRemoved() //Remove and test return type $this->assertTrue(FilterWPQuery::removeFilter()); //Make sure removeFilter() had the right effect -- the filter was removed - $this->assertFalse(has_filter('posts_pre_query', [FilterWPQuery::class, 'callback'])); + $this->assertFalse(has_filter('posts_pre_query', [FilterWPQuery::class, 'filterPreQuery'])); } @@ -62,7 +62,7 @@ public function testNotFilteringByDefault() //Add filter FilterWPQuery::addFilter(); //Test that the filter SHOULD not do anything - $this->assertFalse(FilterWPQuery::shouldFilter()); + $this->assertFalse(FilterWPQuery::shouldFilter([])); //Query for all posts -- should only be one post, the one we just created. $query = new \WP_Query(['post_type' => 'post']); $this->assertFalse(empty($query->posts)); diff --git a/Tests/Integration/RestRequestTest.php b/Tests/Integration/RestRequestTest.php index 1d92d32..5440ac1 100755 --- a/Tests/Integration/RestRequestTest.php +++ b/Tests/Integration/RestRequestTest.php @@ -20,7 +20,7 @@ public function testShouldFilter() $request = new \WP_REST_Request('GET', '/wp/v2/posts'); rest_api_loaded(); //Make sure the method returns true - $this->assertTrue(FilterWPQuery::shouldFilter()); + $this->assertTrue(FilterWPQuery::shouldFilter(null)); } @@ -34,7 +34,7 @@ public function testFilteringRESTRequest() { //Setup filter AlwaysFilterWPQuery::addFilter(); - $this->assertTrue(AlwaysFilterWPQuery::shouldFilter()); + $this->assertTrue(AlwaysFilterWPQuery::shouldFilter(null)); //Create a request $request = new \WP_REST_Request('GET', '/wp/v2/posts'); diff --git a/Tests/Mock/AlwaysFilterWPQuery.php b/Tests/Mock/AlwaysFilterWPQuery.php index 056e6e7..ef508d0 100755 --- a/Tests/Mock/AlwaysFilterWPQuery.php +++ b/Tests/Mock/AlwaysFilterWPQuery.php @@ -7,9 +7,9 @@ class AlwaysFilterWPQuery extends \CalderaLearn\RestSearch\FilterWPQuery { /** @inheritdoc */ - public static function shouldFilter(): bool + public static function shouldFilter($postsOrNull): bool { - return true; + return is_null($postsOrNull); } /** @inheritdoc */ diff --git a/Tests/Mock/FilterWPQuery.php b/Tests/Mock/FilterWPQuery.php index 78d419d..4af969c 100755 --- a/Tests/Mock/FilterWPQuery.php +++ b/Tests/Mock/FilterWPQuery.php @@ -13,9 +13,9 @@ class FilterWPQuery extends \CalderaLearn\RestSearch\FilterWPQuery { /** @inheritdoc */ - public static function shouldFilter() :bool + public static function shouldFilter($postsOrNull) :bool { - return true; + return is_null($postsOrNull); } /** @inheritdoc */ diff --git a/Tests/Unit/FilterWPQueryTest.php b/Tests/Unit/FilterWPQueryTest.php index c0234bc..9bb892f 100755 --- a/Tests/Unit/FilterWPQueryTest.php +++ b/Tests/Unit/FilterWPQueryTest.php @@ -68,7 +68,7 @@ public function testGetPostsArePosts() */ public function testShouldFilter() { - $this->assertTrue(FilterWPQuery::shouldFilter()); + $this->assertTrue(FilterWPQuery::shouldFilter(null)); } /**