Skip to content

Commit

Permalink
Use expect exception
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceKLWilliams committed Mar 20, 2024
1 parent 27681e3 commit adf9eff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
10 changes: 2 additions & 8 deletions tests/Unit/PostQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ public function can_create_a_builder_from_static_functions()
*/
public function throw_error_on_missing_static_function()
{
$errorThrown = false;
$this->expectException(Throwable::class);

try {
Post::missingStaticFunction();
} catch (Throwable $e) {
$errorThrown = true;
}

$this->assertTrue($errorThrown);
Post::missingStaticFunction();
}

private function assertQueryBuilder($function, $params, $postType)
Expand Down
12 changes: 3 additions & 9 deletions tests/Unit/ScopedQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,10 @@ public function can_pass_params_into_a_query_scope_on_post_object()
*/
public function missing_query_scope_throws_an_error()
{
$errorThrown = false;
$this->expectException(Throwable::class);

try {
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
$builder->nonExistentScope();
} catch (Throwable $e) {
$errorThrown = true;
}

$this->assertTrue($errorThrown);
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
$builder->nonExistentScope();
}

/** @test */
Expand Down

0 comments on commit adf9eff

Please sign in to comment.