Skip to content

Commit adf9eff

Browse files
Use expect exception
1 parent 27681e3 commit adf9eff

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

tests/Unit/PostQueryBuilderTest.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,9 @@ public function can_create_a_builder_from_static_functions()
5151
*/
5252
public function throw_error_on_missing_static_function()
5353
{
54-
$errorThrown = false;
54+
$this->expectException(Throwable::class);
5555

56-
try {
57-
Post::missingStaticFunction();
58-
} catch (Throwable $e) {
59-
$errorThrown = true;
60-
}
61-
62-
$this->assertTrue($errorThrown);
56+
Post::missingStaticFunction();
6357
}
6458

6559
private function assertQueryBuilder($function, $params, $postType)

tests/Unit/ScopedQueryBuilderTest.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,10 @@ public function can_pass_params_into_a_query_scope_on_post_object()
115115
*/
116116
public function missing_query_scope_throws_an_error()
117117
{
118-
$errorThrown = false;
118+
$this->expectException(Throwable::class);
119119

120-
try {
121-
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
122-
$builder->nonExistentScope();
123-
} catch (Throwable $e) {
124-
$errorThrown = true;
125-
}
126-
127-
$this->assertTrue($errorThrown);
120+
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
121+
$builder->nonExistentScope();
128122
}
129123

130124
/** @test */

0 commit comments

Comments
 (0)