Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TestsValueObjectConstructor | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| className | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| provideFromNative | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| it_can_be_instantiated_with_fromNative | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Fixtures\TestHelpers; |
| 3 | |
| 4 | use Apie\Core\ValueObjects\ValueObjectInterface; |
| 5 | use PHPUnit\Framework\Attributes\DataProvider; |
| 6 | use PHPUnit\Framework\Attributes\Test; |
| 7 | |
| 8 | trait TestsValueObjectConstructor |
| 9 | { |
| 10 | /** |
| 11 | * @return class-string<ValueObjectInterface> |
| 12 | */ |
| 13 | abstract public static function className(): string; |
| 14 | |
| 15 | /** |
| 16 | * @return array<array-key, array{0: mixed, 1: mixed}> |
| 17 | */ |
| 18 | abstract public static function provideFromNative(): array; |
| 19 | |
| 20 | #[Test] |
| 21 | #[DataProvider('provideFromNative')] |
| 22 | public function it_can_be_instantiated_with_fromNative(mixed $expected, mixed $input): void |
| 23 | { |
| 24 | $className = static::className(); |
| 25 | $valueObject = new $className($input); |
| 26 | $this->assertEquals($expected, $valueObject->toNative()); |
| 27 | } |
| 28 | } |