| Total Complexity | 4 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class PropertyMetadataTest extends TestCase |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param mixed $value |
||
| 17 | * |
||
| 18 | * @dataProvider validTypeValidationExamples |
||
| 19 | */ |
||
| 20 | public function testValidatesValuesMatchingType(Type $type, $value) : void |
||
| 21 | { |
||
| 22 | $metadata = PropertyMetadataMother::withType($type); |
||
| 23 | |||
| 24 | $metadata->validateValue($value); |
||
| 25 | |||
| 26 | $this->assertTrue(true); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return mixed[] |
||
| 31 | */ |
||
| 32 | public function validTypeValidationExamples() : iterable |
||
| 33 | { |
||
| 34 | yield 'valid string' => [ |
||
|
|
|||
| 35 | new StringType(), |
||
| 36 | 'foo', |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param mixed $value |
||
| 42 | * |
||
| 43 | * @dataProvider invalidTypeValidationExamples |
||
| 44 | */ |
||
| 45 | public function testNotValidatesValuesNotMatchingTypeAndThrows(Type $type, $value) : void |
||
| 46 | { |
||
| 47 | $metadata = PropertyMetadataMother::withType($type); |
||
| 48 | |||
| 49 | $this->expectException(InvalidPropertyValue::class); |
||
| 50 | |||
| 51 | $metadata->validateValue($value); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return mixed[] |
||
| 56 | */ |
||
| 57 | public function invalidTypeValidationExamples() : iterable |
||
| 62 | ]; |
||
| 63 | } |
||
| 64 | } |
||
| 65 |