diff --git a/src/Actions/MockActionResponse.php b/src/Actions/MockActionResponse.php index 9d5b70d..69ce732 100644 --- a/src/Actions/MockActionResponse.php +++ b/src/Actions/MockActionResponse.php @@ -4,12 +4,13 @@ use JoshGaber\NovaUnit\Constraints\IsActionResponseType; use PHPUnit\Framework\Assert as PHPUnit; +use PHPUnit\Framework\Constraint\IsType; class MockActionResponse { private $response; - public function __construct($response) + public function __construct($response = null) { $this->response = $response; } @@ -25,7 +26,10 @@ public function assertResponseType(string $type, string $message = ''): self { PHPUnit::assertThat( $this->response, - new IsActionResponseType($type), + PHPUnit::logicalAnd( + new IsType('array'), + new IsActionResponseType($type) + ), $message ); diff --git a/tests/Feature/Actions/MockActionResponseTest.php b/tests/Feature/Actions/MockActionResponseTest.php index 76c3c62..cffc086 100644 --- a/tests/Feature/Actions/MockActionResponseTest.php +++ b/tests/Feature/Actions/MockActionResponseTest.php @@ -138,4 +138,11 @@ public function testItFailsWhenThereIsNoDangerMessage() $mockActionResponse = new MockActionResponse(Action::message('Test Message')); $mockActionResponse->assertDangerContains('test'); } + + public function testItFailsOnNoResponse() + { + $this->shouldFail(); + $mockActionResponse = new MockActionResponse(); + $mockActionResponse->assertResponseType('message'); + } }