diff --git a/.travis.yml b/.travis.yml index def9a8a..cfb5cea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,22 +2,24 @@ language: php php: - 7.1 - - nightly + - 7.2 -matrix: - allow_failures: - - php: nightly - fast_finish: true +env: + - SYMFONY_VERSION=3.3.* + - SYMFONY_VERSION=3.4.* + - SYMFONY_VERSION=4.0.* cache: directories: - - vendor + - ~/.composer/cache/files before_install: - phpenv config-rm xdebug.ini || true install: - - composer update --prefer-dist + - composer require symfony/dependency-injection:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist + - composer require --dev symfony/http-kernel:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist + - composer update --prefer-dist $PREFER_LOWEST script: - composer validate --strict diff --git a/composer.json b/composer.json index 792c7a9..3e7e3b5 100644 --- a/composer.json +++ b/composer.json @@ -13,16 +13,16 @@ "php": "^7.1", "behat/behat": "^3.1", - "symfony/dependency-injection": "^2.8|^3.0" + "symfony/dependency-injection": "^3.3|^4.0" }, "require-dev": { "friends-of-behat/test-context": "^1.0", - "phpspec/phpspec": "^4.0@alpha", - "symfony/http-kernel": "^2.8|^3.0", - "phpunit/phpunit": "^5.7.13|^6.0" + "phpspec/phpspec": "^4.0", + "symfony/http-kernel": "^3.3|^4.0", + "phpunit/phpunit": "^6.0" }, "suggest": { - "symfony/http-kernel": "^2.8|^3.0" + "symfony/http-kernel": "^3.3|^4.0" }, "autoload": { "psr-4": { "FriendsOfBehat\\CrossContainerExtension\\": "src/" } diff --git a/spec/ContainerBasedContainerAccessorSpec.php b/spec/ContainerBasedContainerAccessorSpec.php index bbe01b7..b20e684 100644 --- a/spec/ContainerBasedContainerAccessorSpec.php +++ b/spec/ContainerBasedContainerAccessorSpec.php @@ -41,7 +41,7 @@ function it_gets_a_service(Container $container): void function it_gets_parameters_from_frozen_container(Container $container): void { - $container->isFrozen()->willReturn(true); + $container->isCompiled()->willReturn(true); $container->getParameterBag()->willReturn(new ParameterBag(['name' => 'value'])); $this->getParameters()->shouldReturn(['name' => 'value']); @@ -49,7 +49,7 @@ function it_gets_parameters_from_frozen_container(Container $container): void function it_gets_parameters_from_not_frozen_container(Container $container): void { - $container->isFrozen()->willReturn(false); + $container->isCompiled()->willReturn(false); $container->getParameterBag()->willReturn(new ParameterBag(['name' => 'value'])); $this->getParameters()->shouldReturn(['name' => 'value']); diff --git a/spec/KernelBasedContainerAccessorSpec.php b/spec/KernelBasedContainerAccessorSpec.php index 4ec5d94..31f5d41 100644 --- a/spec/KernelBasedContainerAccessorSpec.php +++ b/spec/KernelBasedContainerAccessorSpec.php @@ -53,7 +53,7 @@ function it_gets_parameters_from_frozen_container(KernelInterface $kernel, Conta { $kernel->getContainer()->willReturn($container); - $container->isFrozen()->willReturn(true); + $container->isCompiled()->willReturn(true); $container->getParameterBag()->willReturn(new ParameterBag(['name' => 'value'])); $this->getParameters()->shouldReturn(['name' => 'value']); @@ -63,7 +63,7 @@ function it_gets_parameters_from_not_frozen_container(KernelInterface $kernel, C { $kernel->getContainer()->willReturn($container); - $container->isFrozen()->willReturn(false); + $container->isCompiled()->willReturn(false); $container->getParameterBag()->willReturn(new ParameterBag(['name' => 'value'])); $this->getParameters()->shouldReturn(['name' => 'value']); diff --git a/src/ContainerBasedContainerAccessor.php b/src/ContainerBasedContainerAccessor.php index 39c4590..8d69f89 100644 --- a/src/ContainerBasedContainerAccessor.php +++ b/src/ContainerBasedContainerAccessor.php @@ -45,7 +45,7 @@ public function getParameters(): array { $parameterBag = $this->container->getParameterBag(); - if (!$this->container->isFrozen()) { + if (!$this->container->isCompiled()) { $parameterBag = clone $parameterBag; $parameterBag->resolve(); } diff --git a/tests/CrossContainerProcessorTest.php b/tests/CrossContainerProcessorTest.php index 7feddb1..14b296e 100644 --- a/tests/CrossContainerProcessorTest.php +++ b/tests/CrossContainerProcessorTest.php @@ -29,12 +29,12 @@ final class CrossContainerProcessorTest extends TestCase public function it_resolves_cross_container_references_in_service_argument(): void { $externalContainer = new ContainerBuilder(); - $externalContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [['foo' => 'bar']])); + $externalContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [['foo' => 'bar']]))->setPublic(true)); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [ + $baseContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [ new Reference('__external__.array_object'), - ])); + ]))->setPublic(true)); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); @@ -48,12 +48,12 @@ public function it_resolves_cross_container_references_in_service_argument(): vo public function it_resolves_cross_container_references_in_service_argument_array(): void { $externalContainer = new ContainerBuilder(); - $externalContainer->setDefinition('std_class', new Definition(\stdClass::class)); + $externalContainer->setDefinition('std_class', (new Definition(\stdClass::class))->setPublic(true)); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [ + $baseContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [ ['std' => ['class' => new Reference('__external__.std_class')]], - ])); + ]))->setPublic(true)); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); @@ -67,14 +67,14 @@ public function it_resolves_cross_container_references_in_service_argument_array public function it_resolves_cross_container_references_in_service_argument_anonymous_definition(): void { $externalContainer = new ContainerBuilder(); - $externalContainer->setDefinition('std_class', new Definition(\stdClass::class)); + $externalContainer->setDefinition('std_class', (new Definition(\stdClass::class))->setPublic(true)); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [ + $baseContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [ new Definition(\ArrayObject::class, [ ['std_class' => new Reference('__external__.std_class')], ]), - ])); + ]))->setPublic(true)); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); @@ -88,11 +88,14 @@ public function it_resolves_cross_container_references_in_service_argument_anony public function it_resolves_cross_container_references_in_service_factory(): void { $externalContainer = new ContainerBuilder(); - $externalContainer->setDefinition('array_object_factory', new Definition(\ArrayObject::class, [['old' => 'old']])); + $externalContainer->setDefinition('array_object_factory', (new Definition(\ArrayObject::class, [['old' => 'old']]))->setPublic(true)); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', - (new Definition(\ArrayObject::class, [['new' => 'new']]))->setFactory([new Reference('__external__.array_object_factory'), 'exchangeArray']) + $baseContainer->setDefinition( + 'array_object', + (new Definition(\ArrayObject::class, [['new' => 'new']])) + ->setFactory([new Reference('__external__.array_object_factory'), 'exchangeArray']) + ->setPublic(true) ); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); @@ -142,9 +145,11 @@ public function it_resolves_cross_container_parameters_in_service_definition_arr $externalContainer->setParameter('parameter', '42'); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [ - ['parameter' => '%__external__.parameter%'], - ])); + $baseContainer->setDefinition( + 'array_object', + (new Definition(\ArrayObject::class, [['parameter' => '%__external__.parameter%']])) + ->setPublic(true) + ); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]); @@ -190,10 +195,15 @@ public function it_resolves_cross_container_escaped_parameters_symfony_kernel(): public function it_resolves_cross_container_references_in_method_calls(): void { $externalContainer = new ContainerBuilder(); - $externalContainer->setDefinition('array_object', new Definition(\ArrayObject::class, [['foo' => 'bar']])); + $externalContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [['foo' => 'bar']]))->setPublic(true)); $baseContainer = new ContainerBuilder(); - $baseContainer->setDefinition('array_object', (new Definition(\ArrayObject::class, [[]]))->addMethodCall('exchangeArray', [new Reference('__external__.array_object')])); + $baseContainer->setDefinition( + 'array_object', + (new Definition(\ArrayObject::class, [[]])) + ->addMethodCall('exchangeArray', [new Reference('__external__.array_object')]) + ->setPublic(true) + ); $this->buildContainerWithDependencies($baseContainer, ['external' => $externalContainer]);