|
12 | 12 | namespace Symfony\Component\TypeInfo\Tests; |
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait; |
15 | 16 | use Symfony\Component\TypeInfo\Tests\Fixtures\DummyBackedEnum; |
16 | 17 | use Symfony\Component\TypeInfo\Tests\Fixtures\DummyEnum; |
17 | 18 | use Symfony\Component\TypeInfo\Type; |
|
29 | 30 |
|
30 | 31 | class TypeFactoryTest extends TestCase |
31 | 32 | { |
| 33 | + use ExpectUserDeprecationMessageTrait; |
| 34 | + |
32 | 35 | public function testCreateBuiltin() |
33 | 36 | { |
34 | 37 | $this->assertEquals(new BuiltinType(TypeIdentifier::INT), Type::builtin(TypeIdentifier::INT)); |
@@ -136,15 +139,6 @@ public function testCreateIterable() |
136 | 139 | )), |
137 | 140 | Type::iterable(Type::bool(), Type::string()), |
138 | 141 | ); |
139 | | - |
140 | | - $this->assertEquals( |
141 | | - new CollectionType(new GenericType( |
142 | | - new<
5C9C
/span> BuiltinType(TypeIdentifier::ITERABLE), |
143 | | - new BuiltinType(TypeIdentifier::INT), |
144 | | - new BuiltinType(TypeIdentifier::BOOL), |
145 | | - ), isList: true), |
146 | | - Type::iterable(Type::bool(), Type::int(), true), |
147 | | - ); |
148 | 142 | } |
149 | 143 |
|
150 | 144 | public function testCreateObject() |
@@ -263,4 +257,13 @@ public function offsetUnset(mixed $offset): void |
263 | 257 | yield [Type::collection(Type::object(\Generator::class), Type::string(), Type::int()), (fn (): iterable => yield 'string')()]; |
264 | 258 | yield [Type::collection(Type::object($arrayAccess::class)), $arrayAccess]; |
265 | 259 | } |
| 260 | + |
| 261 | + /** |
| 262 | + * @group legacy |
| 263 | + */ |
| 264 | + public function testCannotCreateIterableList() |
| 265 | + { |
| 266 | + $this->expectUserDeprecationMessage('Since symfony/type-info 7.3: The third argument of "Symfony\Component\TypeInfo\TypeFactoryTrait::iterable()" is deprecated. Use the "Symfony\Component\TypeInfo\Type::list()" method to create a list instead.'); |
| 267 | + Type::iterable(key: Type::int(), asList: true); |
| 268 | + } |
266 | 269 | } |
0 commit comments