Skip to content

Commit

Permalink
[ECVS-6] fixed test.
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanim committed Dec 23, 2023
1 parent 2ac62d2 commit 786a7fd
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/unit/exceptions/service/UnknownServiceErrorExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace rocketfellows\ViesVatValidationInterface\tests\unit\exceptions\service;

use Exception;
use PHPUnit\Framework\TestCase;
use rocketfellows\ViesVatValidationInterface\exceptions\service\UnknownServiceErrorException;

Expand Down Expand Up @@ -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());
Expand All @@ -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' => [
Expand All @@ -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,
],
],
];
}
}

0 comments on commit 786a7fd

Please sign in to comment.