X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FIntegrationTest.php;fp=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FIntegrationTest.php;h=15c827d8270df502f2d14c1605ee8f642b48c41d;hp=db33d4b4a14dc1ba90a69117d35f6024bcb6cb8e;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php b/vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php index db33d4b4a..15c827d82 100644 --- a/vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php +++ b/vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php @@ -12,7 +12,9 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -114,4 +116,109 @@ class IntegrationTest extends TestCase $this->assertFalse($container->hasDefinition('b')); $this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.'); } + + /** + * @dataProvider getYamlCompileTests + */ + public function testYamlContainerCompiles($directory, $actualServiceId, $expectedServiceId, ContainerBuilder $mainContainer = null) + { + // allow a container to be passed in, which might have autoconfigure settings + $container = $mainContainer ? $mainContainer : new ContainerBuilder(); + $container->setResourceTracking(false); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Fixtures/yaml/integration/'.$directory)); + $loader->load('main.yml'); + $container->compile(); + $actualService = $container->getDefinition($actualServiceId); + + // create a fresh ContainerBuilder, to avoid autoconfigure stuff + $container = new ContainerBuilder(); + $container->setResourceTracking(false); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Fixtures/yaml/integration/'.$directory)); + $loader->load('expected.yml'); + $container->compile(); + $expectedService = $container->getDefinition($expectedServiceId); + + // reset changes, we don't care if these differ + $actualService->setChanges(array()); + $expectedService->setChanges(array()); + + $this->assertEquals($expectedService, $actualService); + } + + public function getYamlCompileTests() + { + $container = new ContainerBuilder(); + $container->registerForAutoconfiguration(IntegrationTestStub::class); + yield array( + 'autoconfigure_child_not_applied', + 'child_service', + 'child_service_expected', + $container, + ); + + $container = new ContainerBuilder(); + $container->registerForAutoconfiguration(IntegrationTestStub::class); + yield array( + 'autoconfigure_parent_child', + 'child_service', + 'child_service_expected', + $container, + ); + + $container = new ContainerBuilder(); + $container->registerForAutoconfiguration(IntegrationTestStub::class) + ->addTag('from_autoconfigure'); + yield array( + 'autoconfigure_parent_child_tags', + 'child_service', + 'child_service_expected', + $container, + ); + + yield array( + 'child_parent', + 'child_service', + 'child_service_expected', + ); + + yield array( + 'defaults_child_tags', + 'child_service', + 'child_service_expected', + ); + + yield array( + 'defaults_instanceof_importance', + 'main_service', + 'main_service_expected', + ); + + yield array( + 'defaults_parent_child', + 'child_service', + 'child_service_expected', + ); + + yield array( + 'instanceof_parent_child', + 'child_service', + 'child_service_expected', + ); + } +} + +class IntegrationTestStub extends IntegrationTestStubParent +{ +} + +class IntegrationTestStubParent +{ + public function enableSummer($enable) + { + // methods used in calls - added here to prevent errors for not existing + } + + public function setSunshine($type) + { + } }