|
5 | 5 |
|
6 | 6 | use PHPUnit\Framework\TestCase;
|
7 | 7 | use Prophecy\Prophecy\ObjectProphecy;
|
| 8 | +use Symfony\Component\Config\Resource\ReflectionClassResource; |
8 | 9 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
9 | 10 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
10 | 11 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
@@ -78,4 +79,23 @@ public function test_it_only_registers_a_service_locator_if_any_services_were_di
|
78 | 79 | $this->assertfalse($container->hasDefinition(TestCase1::class), 'The first test case service locator is not registered as a service.');
|
79 | 80 | $this->assertfalse($container->hasDefinition(TestCase2::class), 'The second test case service locator is not registered as a service.');
|
80 | 81 | }
|
| 82 | + |
| 83 | + public function test_it_registers_test_cases_as_container_resources() |
| 84 | + { |
| 85 | + $this->discovery->run()->willReturn([ |
| 86 | + new Property(TestCase1::class, 'service1', Service1::class), |
| 87 | + new Property(TestCase1::class, 'service2', Service2::class), |
| 88 | + new Property(TestCase2::class, 'service2', Service2::class), |
| 89 | + ]); |
| 90 | + |
| 91 | + $container = new ContainerBuilder(); |
| 92 | + $this->pass->process($container); |
| 93 | + |
| 94 | + $resources = $container->getResources(); |
| 95 | + |
| 96 | + $this->assertCount(2, $resources); |
| 97 | + $this->assertContainsOnlyInstancesOf(ReflectionClassResource::class, $resources); |
| 98 | + $this->assertRegExp('#'.\preg_quote(TestCase1::class, '#').'#', (string) $resources[0]); |
| 99 | + $this->assertRegExp('#'.\preg_quote(TestCase2::class, '#').'#', (string) $resources[1]); |
| 100 | + } |
81 | 101 | }
|
0 commit comments