Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| TestValidationError | n/a |
0 / 0 |
n/a |
0 / 0 |
3 | n/a |
0 / 0 |
|||
| assertValidationError | n/a |
0 / 0 |
n/a |
0 / 0 |
3 | |||||
| 1 | <?php |
| 2 | namespace Apie\Fixtures\TestHelpers; |
| 3 | |
| 4 | use Apie\Serializer\Exceptions\ValidationException; |
| 5 | use Throwable; |
| 6 | |
| 7 | /** @codeCoverageIgnore */ |
| 8 | trait TestValidationError |
| 9 | { |
| 10 | public function assertValidationError(array $expectedErrorMessages, callable $testCase) |
| 11 | { |
| 12 | try { |
| 13 | $testCase(); |
| 14 | } catch (Throwable $error) { |
| 15 | if (class_exists(ValidationException::class)) { |
| 16 | $this->assertInstanceOf(ValidationException::class, $error); |
| 17 | $this->assertEquals($expectedErrorMessages, $error->getErrors()->toArray()); |
| 18 | } |
| 19 | $this->assertTrue(true, 'it works as intended'); |
| 20 | return; |
| 21 | } |
| 22 | $this->fail('No validation error was thrown!'); |
| 23 | } |
| 24 | } |