diff --git a/src/ScopedQueryBuilder.php b/src/ScopedQueryBuilder.php index 100b69e..f6089c1 100644 --- a/src/ScopedQueryBuilder.php +++ b/src/ScopedQueryBuilder.php @@ -23,7 +23,6 @@ public function __construct($postClass) $this->queryBuilder = Helpers::app(QueryBuilderContract::class); $this->queryBuilder - ->as($postClass) ->wherePostType(call_user_func([$this->postClass, 'getPostType'])); } @@ -65,7 +64,7 @@ public function __call($name, $arguments) * @param string $name The method name * @return boolean */ - protected function hasQueryBuilderMethod(string $name) : bool + protected function hasQueryBuilderMethod(string $name): bool { if (method_exists($this->queryBuilder, $name)) { return true; @@ -82,9 +81,4 @@ public function wherePostType($postType) { throw new CannotRedeclarePostTypeOnQueryException; } - - public function as($postClass) - { - throw new CannotRedeclarePostClassOnQueryException; - } } diff --git a/tests/Unit/ScopedQueryBuilderTest.php b/tests/Unit/ScopedQueryBuilderTest.php index 655231f..33ad032 100644 --- a/tests/Unit/ScopedQueryBuilderTest.php +++ b/tests/Unit/ScopedQueryBuilderTest.php @@ -48,21 +48,12 @@ public function cannot_overwrite_post_type() $builder->wherePostType('test_post_type'); } - /** @test */ - public function cannot_overwrite_post_class() - { - $this->expectException(\Rareloop\Lumberjack\Exceptions\CannotRedeclarePostClassOnQueryException::class); - - $builder = new ScopedQueryBuilder(PostWithQueryScope::class); - $builder->as(Post::class); - } - /** * @test * @runInSeparateProcess * @preserveGlobalState disabled */ - public function get_retrieves_list_of_posts_of_correct_type() + public function get_retrieves_list_of_posts() { $posts = [new PostWithQueryScope(1, true), new PostWithQueryScope(2, true)]; @@ -73,7 +64,6 @@ public function get_retrieves_list_of_posts_of_correct_type() 'post_status' => 'publish', 'offset' => 10, ]), - PostWithQueryScope::class, ])->once()->andReturn($posts); $builder = new ScopedQueryBuilder(PostWithQueryScope::class);