diff --git a/tests/unit/exceptions/service/UnknownServiceErrorExceptionTest.php b/tests/unit/exceptions/service/UnknownServiceErrorExceptionTest.php index d42f224..1c1ae63 100644 --- a/tests/unit/exceptions/service/UnknownServiceErrorExceptionTest.php +++ b/tests/unit/exceptions/service/UnknownServiceErrorExceptionTest.php @@ -2,6 +2,7 @@ namespace rocketfellows\ViesVatValidationInterface\tests\unit\exceptions\service; +use Exception; use PHPUnit\Framework\TestCase; use rocketfellows\ViesVatValidationInterface\exceptions\service\UnknownServiceErrorException; @@ -52,11 +53,16 @@ public function getDefaultCreateExceptionProvidedData(): array } /** - * @dataProvider getDefaultCreateExceptionProvidedData + * @dataProvider getCreateExceptionProvidedData */ public function testCreateException(array $exceptionData, array $expectedExceptionData): void { - $exception = new UnknownServiceErrorException($exceptionData['faultCode']); + $exception = new UnknownServiceErrorException( + $exceptionData['faultCode'], + $exceptionData['message'], + $exceptionData['code'], + $exceptionData['prevException'] + ); $this->assertEquals($expectedExceptionData['expectedFaultCode'], $exception->getFaultCode()); $this->assertEquals($expectedExceptionData['expectedMessage'], $exception->getMessage()); @@ -66,6 +72,8 @@ public function testCreateException(array $exceptionData, array $expectedExcepti public function getCreateExceptionProvidedData(): array { + $prevException = new Exception(); + return [ 'fault code empty, message empty, default code, prev exception not set' => [ 'exceptionData' => [ @@ -81,6 +89,20 @@ public function getCreateExceptionProvidedData(): array 'expectedPrevException' => null, ], ], + 'fault code not empty, message not empty, not default code, prev exception set' => [ + 'exceptionData' => [ + 'faultCode' => 'foo', + 'message' => 'foo bar', + 'code' => 1, + 'prevException' => $prevException, + ], + 'expectedExceptionData' => [ + 'expectedFaultCode' => 'foo', + 'expectedMessage' => 'foo bar', + 'expectedCode' => 1, + 'expectedPrevException' => $prevException, + ], + ], ]; } }