|
7 | 7 | use Constructo\Contract\Reflect\TypesFactory; |
8 | 8 | use Constructo\Core\Reflect\Introspection\Introspector; |
9 | 9 | use Constructo\Core\Reflect\Reflector; |
| 10 | +use Constructo\Core\Serialize\Builder; |
10 | 11 | use Constructo\Factory\DefaultSpecsFactory; |
11 | 12 | use Constructo\Factory\SchemaFactory; |
12 | 13 | use Constructo\Support\Cache; |
|
16 | 17 | use Constructo\Test\Stub\Domain\Entity\Command\PersonCommand; |
17 | 18 | use Constructo\Test\Stub\Domain\Entity\EmptyClass; |
18 | 19 | use Constructo\Test\Stub\Reflector\Sample; |
| 20 | +use Constructo\Testing\MakeExtension; |
19 | 21 | use PHPUnit\Framework\TestCase; |
20 | 22 |
|
21 | 23 | use function json_decode; |
22 | 24 |
|
23 | | -final class ReflectorTest extends TestCase |
| 25 | +class ReflectorTest extends TestCase |
24 | 26 | { |
| 27 | + use MakeExtension; |
| 28 | + |
25 | 29 | private Reflector $reflector; |
26 | 30 |
|
27 | 31 | protected function setUp(): void |
28 | 32 | { |
29 | | - $types = new Types(); |
30 | | - $cache = new Cache(); |
31 | | - $introspector = new Introspector(); |
| 33 | + $types = $this->make(Types::class); |
| 34 | + $cache = $this->make(Cache::class); |
| 35 | + $builder = $this->make(Builder::class); |
| 36 | + $introspector = $this->make(Introspector::class); |
32 | 37 | $notation = Notation::SNAKE; |
33 | 38 |
|
34 | 39 | $typesFactory = $this->createMock(TypesFactory::class); |
@@ -72,7 +77,7 @@ protected function setUp(): void |
72 | 77 | 'size' => ['params' => ['size']], |
73 | 78 | ]; |
74 | 79 |
|
75 | | - $specsFactory = new DefaultSpecsFactory($specsData); |
| 80 | + $specsFactory = new DefaultSpecsFactory($builder, $specsData); |
76 | 81 | $schemaFactory = new SchemaFactory($specsFactory); |
77 | 82 |
|
78 | 83 |
|
@@ -295,10 +300,16 @@ public function __construct( |
295 | 300 |
|
296 | 301 | // Should have the field but no nested rules since EmptyClass has no parameters |
297 | 302 | $this->assertArrayHasKey('empty_field', $rules); |
298 | | - $this->assertEquals(['required', 'array'], $rules['empty_field']); |
| 303 | + $this->assertEquals( |
| 304 | + [ |
| 305 | + 'required', |
| 306 | + 'array', |
| 307 | + ], |
| 308 | + $rules['empty_field'] |
| 309 | + ); |
299 | 310 |
|
300 | 311 | // Should not have any nested rules for empty_field since EmptyClass has no constructor parameters |
301 | | - $nestedKeys = array_filter(array_keys($rules), fn($key) => str_starts_with($key, 'empty_field.')); |
| 312 | + $nestedKeys = array_filter(array_keys($rules), fn ($key) => str_starts_with($key, 'empty_field.')); |
302 | 313 | $this->assertEmpty($nestedKeys); |
303 | 314 | } |
304 | 315 | } |
0 commit comments