Skip to content

Commit bdfc416

Browse files
committed
fix: always assert
When performing try/catch blocks, and the catch represents a valid condition, we need to assert SOMETHING, or else the test is flagged as risky. A simple assertion that we got a throwable works in these cases.
1 parent c8feb97 commit bdfc416

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

src/MessageTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public function testWithHeaderInvalidArguments($name, $value)
145145
$initialMessage->withHeader($name, $value);
146146
} catch (TypeError|InvalidArgumentException $e) {
147147
// valid
148+
$this->assertTrue($e instanceof Throwable);
148149
} catch (Throwable $e) {
149150
// invalid
150151
$this->fail(sprintf(
@@ -193,6 +194,7 @@ public function testWithAddedHeaderInvalidArguments($name, $value)
193194
$initialMessage->withAddedHeader($name, $value);
194195
} catch (TypeError|InvalidArgumentException $e) {
195196
// valid
197+
$this->assertTrue($e instanceof Throwable);
196198
} catch (Throwable $e) {
197199
// invalid
198200
$this->fail(sprintf(

src/RequestIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function testMethodWithInvalidArguments($method)
103103
$this->request->withMethod($method);
104104
} catch (InvalidArgumentException|TypeError $e) {
105105
// valid
106+
$this->assertTrue($e instanceof Throwable);
106107
} catch (Throwable $e) {
107108
// invalid
108109
$this->fail(sprintf(

src/ResponseIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function testStatusCodeInvalidArgument($statusCode)
6565
$this->response->withStatus($statusCode);
6666
} catch (InvalidArgumentException|TypeError $e) {
6767
// valid
68+
$this->assertTrue($e instanceof Throwable);
6869
} catch (Throwable $e) {
6970
// invalid
7071
$this->fail(sprintf(

src/UriIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function testWithSchemeInvalidArguments($schema)
5454
$this->createUri('/')->withScheme($schema);
5555
} catch (InvalidArgumentException|TypeError $e) {
5656
// valid
57+
$this->assertTrue($e instanceof Throwable);
5758
} catch (Throwable $e) {
5859
// invalid
5960
$this->fail(sprintf(

0 commit comments

Comments
 (0)