|
4 | 4 |
|
5 | 5 | namespace Flow\Types\Tests\Unit\Type\Logical; |
6 | 6 |
|
7 | | -use function Flow\Types\DSL\{type_float, type_from_array, type_integer, type_optional, type_string, type_union}; |
| 7 | +use function Flow\Types\DSL\{type_float, |
| 8 | + type_from_array, |
| 9 | + type_integer, |
| 10 | + type_mixed, |
| 11 | + type_optional, |
| 12 | + type_string, |
| 13 | + type_union}; |
8 | 14 | use Flow\Types\Type\Logical\OptionalType; |
9 | 15 | use PHPUnit\Framework\Attributes\DataProvider; |
10 | 16 | use PHPUnit\Framework\TestCase; |
@@ -40,12 +46,33 @@ public function test_creating_optional_type_from_another_optional_type() : void |
40 | 46 | type_optional(type_optional(type_float())); |
41 | 47 | } |
42 | 48 |
|
| 49 | + public function test_creating_optional_type_from_mixed_type() : void |
| 50 | + { |
| 51 | + $this->expectExceptionMessage('Optional type cannot be created from MixedType, mixed is a standalone type'); |
| 52 | + |
| 53 | + type_optional(type_mixed()); |
| 54 | + } |
| 55 | + |
| 56 | + public function test_creating_optional_type_from_optional_type() : void |
| 57 | + { |
| 58 | + $this->expectExceptionMessage('Optional type cannot be created from an optional type'); |
| 59 | + |
| 60 | + type_optional(type_optional(type_float())); |
| 61 | + } |
| 62 | + |
43 | 63 | public function test_creating_optional_type_from_union_type() : void |
44 | 64 | { |
45 | 65 | $this->expectExceptionMessage('Optional type cannot be created from a union type'); |
46 | 66 | type_optional(type_union(type_float(), type_string())); |
47 | 67 | } |
48 | 68 |
|
| 69 | + public function test_creating_optional_type_from_union_type_with_mixed() : void |
| 70 | + { |
| 71 | + $this->expectExceptionMessage('Optional type cannot be created from a union type'); |
| 72 | + |
| 73 | + type_optional(type_union(type_float(), type_integer())); |
| 74 | + } |
| 75 | + |
49 | 76 | public function test_normalizing_optional_type() : void |
50 | 77 | { |
51 | 78 | self::assertEquals( |
|
0 commit comments