diff --git a/.travis.yml b/.travis.yml index b2c2fb2..3ab3778 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,20 @@ language: php +dist: trusty php: - 5.5 - 5.6 - 7.0 - - hhvm + - 7.1 + - 7.2 branches: only: - master - /^\d+\.\d+$/ +env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors + sudo: false cache: @@ -22,25 +26,31 @@ matrix: fast_finish: true include: - php: 5.3 - env: SYMFONY_DEPRECATIONS_HELPER=weak + dist: precise - php: 5.3 - env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak + dist: precise + env: SYMFONY_DEPRECATIONS_HELPER COMPOSER_FLAGS="--prefer-lowest" - php: 5.4 - env: SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 - env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=2.7.* - php: 7.0 - env: SYMFONY_VERSION=2.8.* COVERAGE=true SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=2.8.* COVERAGE=true - php: 7.0 - env: SYMFONY_VERSION=3.0.* + env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=3.2.* + - php: 7.1 + env: ~ + allow_failures: + - php: 7.1 + env: ~ before_script: - - if [ "$COVERAGE" != "true" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi + - if [ "$COVERAGE" != "true" ]; then phpenv config-rm xdebug.ini; fi - composer self-update - if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi - - composer update $COMPOSER_FLAGS --prefer-source + - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - composer update $COMPOSER_FLAGS --prefer-dist --no-interaction -script: if [ "$COVERAGE" == "true" ]; then ./phpunit --coverage-clover=clover; else ./phpunit; fi +script: if [ "$COVERAGE" == "true" ]; then vendor/bin/phpunit --coverage-clover=clover; else vendor/bin/phpunit; fi after_success: - if [ "$COVERAGE" == "true" ]; then curl -sL https://bit.ly/artifact-uploader | php; fi diff --git a/Tests/BaseTestCase.php b/Tests/BaseTestCase.php new file mode 100644 index 0000000..ba5a3d1 --- /dev/null +++ b/Tests/BaseTestCase.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests; + +use PHPUnit\Framework\TestCase; + +abstract class BaseTestCase extends TestCase +{ + final protected function createMock($class) + { + if (method_exists('PHPUnit\Framework\TestCase', 'createMock')) { + return parent::createMock($class); + } + return $this->getMock($class); + } +} diff --git a/Tests/DependencyInjection/Collection/LazyServiceMapTest.php b/Tests/DependencyInjection/Collection/LazyServiceMapTest.php index fdec00c..a76e4a2 100644 --- a/Tests/DependencyInjection/Collection/LazyServiceMapTest.php +++ b/Tests/DependencyInjection/Collection/LazyServiceMapTest.php @@ -19,10 +19,11 @@ namespace JMS\DiExtraBundle\Tests\DependencyInjection\Collection; use JMS\DiExtraBundle\DependencyInjection\Collection\LazyServiceMap; +use JMS\DiExtraBundle\Tests\BaseTestCase; use PHPUnit_Framework_MockObject_MockObject; use Symfony\Component\DependencyInjection\ContainerInterface; -class LazyServiceMapTest extends \PHPUnit_Framework_TestCase +class LazyServiceMapTest extends BaseTestCase { /** * @var LazyServiceMap @@ -79,7 +80,7 @@ public function testIterator() protected function setUp() { - $this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $this->container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface'); $this->map = new LazyServiceMap($this->container, array( 'foo' => 'bar_service', diff --git a/Tests/DependencyInjection/Collection/LazyServiceSequenceTest.php b/Tests/DependencyInjection/Collection/LazyServiceSequenceTest.php index f1154c9..be2c876 100644 --- a/Tests/DependencyInjection/Collection/LazyServiceSequenceTest.php +++ b/Tests/DependencyInjection/Collection/LazyServiceSequenceTest.php @@ -19,8 +19,9 @@ namespace JMS\DiExtraBundle\Tests\DependencyInjection\Collection; use JMS\DiExtraBundle\DependencyInjection\Collection\LazyServiceSequence; +use JMS\DiExtraBundle\Tests\BaseTestCase; -class LazyServiceSequenceTest extends \PHPUnit_Framework_TestCase +class LazyServiceSequenceTest extends BaseTestCase { private $container; private $seq; @@ -75,7 +76,7 @@ public function testGet() protected function setUp() { - $this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $this->container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface'); $this->seq = new LazyServiceSequence($this->container, array('foo', 'bar', 'baz')); } } diff --git a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php b/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php index c7e8b7e..1fd021d 100644 --- a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php +++ b/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php @@ -21,12 +21,13 @@ use Doctrine\Common\Annotations\AnnotationReader; use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass; use JMS\DiExtraBundle\DependencyInjection\JMSDiExtraExtension; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Filesystem\Filesystem; -class AnnotationConfigurationPassTest extends \PHPUnit_Framework_TestCase +class AnnotationConfigurationPassTest extends TestCase { public function testProcess() { diff --git a/Tests/DependencyInjection/Compiler/LazyServiceMapPassTest.php b/Tests/DependencyInjection/Compiler/LazyServiceMapPassTest.php index bf16f05..4a44406 100644 --- a/Tests/DependencyInjection/Compiler/LazyServiceMapPassTest.php +++ b/Tests/DependencyInjection/Compiler/LazyServiceMapPassTest.php @@ -19,11 +19,12 @@ namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler; use JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceMapPass; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class LazyServiceMapPassTest extends \PHPUnit_Framework_TestCase +class LazyServiceMapPassTest extends TestCase { public function testProcess() { diff --git a/Tests/DependencyInjection/Compiler/LazyServiceSequencePassTest.php b/Tests/DependencyInjection/Compiler/LazyServiceSequencePassTest.php index 7a1cc98..b81af87 100644 --- a/Tests/DependencyInjection/Compiler/LazyServiceSequencePassTest.php +++ b/Tests/DependencyInjection/Compiler/LazyServiceSequencePassTest.php @@ -19,11 +19,12 @@ namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler; use JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceSequencePass; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class LazyServiceSequencePassTest extends \PHPUnit_Framework_TestCase +class LazyServiceSequencePassTest extends TestCase { public function testProcess() { diff --git a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php b/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php index e7ff9be..2441b75 100644 --- a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php +++ b/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php @@ -19,10 +19,11 @@ namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler; use JMS\DiExtraBundle\DependencyInjection\Compiler\ResourceOptimizationPass; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Resource\DirectoryResource; use Symfony\Component\DependencyInjection\ContainerBuilder; -class ResourceOptimizationPassTest extends \PHPUnit_Framework_TestCase +class ResourceOptimizationPassTest extends TestCase { public function testProcess() { diff --git a/Tests/Finder/AbstractPatternFinderTest.php b/Tests/Finder/AbstractPatternFinderTest.php index b54e434..5ddc87e 100644 --- a/Tests/Finder/AbstractPatternFinderTest.php +++ b/Tests/Finder/AbstractPatternFinderTest.php @@ -18,7 +18,9 @@ namespace JMS\DiExtraBundle\Tests\Finder; -abstract class AbstractPatternFinderTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +abstract class AbstractPatternFinderTest extends TestCase { public function testFindFiles() { diff --git a/Tests/Functional/AppKernel.php b/Tests/Functional/AppKernel.php index 3c23eb8..e9e1dd8 100644 --- a/Tests/Functional/AppKernel.php +++ b/Tests/Functional/AppKernel.php @@ -75,6 +75,8 @@ public function registerBundles() new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new \JMS\AopBundle\JMSAopBundle(), + version_compare(PHP_VERSION, '7.0.0', '<')? + new \JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\JMSDiExtraTestBundle(): new \JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\JMSDiExtraTestBundle(), new \JMS\DiExtraBundle\JMSDiExtraBundle(), new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php new file mode 100644 index 0000000..a359847 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AnotherSecuredController.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use JMS\SecurityExtraBundle\Annotation\Secure; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; + +/** + * Secured Controller. + * + * @author Johannes M. Schmitt + */ +class AnotherSecuredController +{ + /** + * @Route("/secure-action") + * @Secure("ROLE_FOO") + */ + public function secureAction() + { + throw new \Exception('Should never be called'); + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/AutomaticallyInjectedController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AutomaticallyInjectedController.php new file mode 100644 index 0000000..9a21c08 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/AutomaticallyInjectedController.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; +use Symfony\Component\Security\Core\SecurityContextInterface; +use Symfony\Component\Templating\EngineInterface; + +class AutomaticallyInjectedController +{ + private $context; + private $templating; + private $router; + private $foo; + + public function setRouter(RouterInterface $router) + { + $this->router = $router; + } + + /** + * @Route("/automatic-controller-injection-test") + */ + public function testAction() + { + $content = ''; + + $content .= sprintf("\$context injection: %s\n", $this->context instanceof SecurityContextInterface || $this->context instanceof AuthorizationCheckerInterface ? 'OK' : 'FAILED'); + $content .= sprintf("\$templating injection: %s\n", $this->templating instanceof EngineInterface ? 'OK' : 'FAILED'); + $content .= sprintf("\$router injection: %s\n", $this->router instanceof RouterInterface ? 'OK' : 'FAILED'); + $content .= sprintf("\$foo injection: %s\n", 'bar' === $this->foo ? 'OK' : 'FAILED'); + + return new Response($content); + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/ExtendedServiceController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/ExtendedServiceController.php new file mode 100644 index 0000000..d84fb2a --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/ExtendedServiceController.php @@ -0,0 +1,33 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use JMS\DiExtraBundle\Annotation as DI; +use Symfony\Component\HttpFoundation\Response; + +/** + * @DI\Service("controller.extended_hello", parent = "controller.hello") + */ +class ExtendedServiceController extends ServiceController +{ + public function helloAction() + { + return new Response('hello'); + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/InvokableServiceController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/InvokableServiceController.php new file mode 100644 index 0000000..dd3264f --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/InvokableServiceController.php @@ -0,0 +1,33 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use JMS\DiExtraBundle\Annotation as DI; +use Symfony\Component\HttpFoundation\Response; + +/** + * @DI\Service("controller.invokable") + */ +class InvokableServiceController +{ + public function __invoke() + { + return new Response('invoked'); + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/RegisterController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/RegisterController.php new file mode 100644 index 0000000..f95ffa7 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/RegisterController.php @@ -0,0 +1,44 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use JMS\DiExtraBundle\Annotation as DI; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Response; + +/** + * @author Johannes M. Schmitt + */ +class RegisterController +{ + /** + * @Route("/register") + */ + public function registerAction() + { + $mailer = $this->getMailer(); + + return new Response($mailer->getFromMail(), 200, array('Content-Type' => 'text/plain')); + } + + /** @DI\LookupMethod("test_mailer") */ + protected function getMailer() + { + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php new file mode 100644 index 0000000..0498951 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/SecuredController.php @@ -0,0 +1,43 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use JMS\DiExtraBundle\Annotation as DI; +use JMS\SecurityExtraBundle\Annotation\Secure; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; + +/** + * @author Johannes M. Schmitt + */ +class SecuredController +{ + /** + * @Route("/lookup-method-and-aop") + * @Secure("ROLE_FOO") + */ + public function secureAction() + { + throw new \Exception('Should never be called'); + } + + /** @DI\LookupMethod */ + protected function getTestMailer() + { + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Controller/ServiceController.php b/Tests/Functional/Bundle/LegacyTestBundle/Controller/ServiceController.php new file mode 100644 index 0000000..24a1cba --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Controller/ServiceController.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller; + +use Symfony\Component\Routing\RouterInterface; + +abstract class ServiceController +{ + public function __construct(RouterInterface $router) + { + // Dummy constructor injection, to make sure inheritance works + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/AbstractClass.php b/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/AbstractClass.php new file mode 100644 index 0000000..7717014 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/AbstractClass.php @@ -0,0 +1,47 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Inheritance; + +use JMS\DiExtraBundle\Annotation as DI; +use Symfony\Component\Templating\EngineInterface; + +/** + * @DI\Service("abstract_class") + * + * @author johannes + */ +abstract class AbstractClass +{ + private $templating; + + /** + * @DI\InjectParams + * + * @param EngineInterface $templating + */ + public function setTemplating(EngineInterface $templating) + { + $this->templating = $templating; + } + + public function getTemplating() + { + return $this->templating; + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/ConcreteClass.php b/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/ConcreteClass.php new file mode 100644 index 0000000..191dff9 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Inheritance/ConcreteClass.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Inheritance; + +use JMS\DiExtraBundle\Annotation as DI; + +/** + * @DI\Service("concrete_class") + * + * @author Johannes M. Schmitt + */ +class ConcreteClass extends AbstractClass +{ + private $foo; + private $bar; + + /** + * @DI\InjectParams + * + * @param stdClass $foo + * @param stdClass $bar + */ + public function __construct($foo, $bar) + { + $this->foo = $foo; + $this->bar = $bar; + } + + public function getFoo() + { + return $this->foo; + } + + public function getBar() + { + return $this->bar; + } +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/JMSDiExtraTestBundle.php b/Tests/Functional/Bundle/LegacyTestBundle/JMSDiExtraTestBundle.php new file mode 100644 index 0000000..3fd31c6 --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/JMSDiExtraTestBundle.php @@ -0,0 +1,25 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class JMSDiExtraTestBundle extends Bundle +{ +} diff --git a/Tests/Functional/Bundle/LegacyTestBundle/Mailer/TestMailer.php b/Tests/Functional/Bundle/LegacyTestBundle/Mailer/TestMailer.php new file mode 100644 index 0000000..d91b46c --- /dev/null +++ b/Tests/Functional/Bundle/LegacyTestBundle/Mailer/TestMailer.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Mailer; + +use JMS\DiExtraBundle\Annotation as DI; + +/** + * @DI\Service("test_mailer") + * + * @author Johannes M. Schmitt + */ +class TestMailer +{ + public function getFromMail() + { + return 'foo@bar.de'; + } +} diff --git a/Tests/Functional/Bundle/TestBundle/Factory/MyFactory.php b/Tests/Functional/Bundle/TestBundle/Factory/MyFactory.php index c762f32..52c7a0d 100644 --- a/Tests/Functional/Bundle/TestBundle/Factory/MyFactory.php +++ b/Tests/Functional/Bundle/TestBundle/Factory/MyFactory.php @@ -12,4 +12,4 @@ public function createGenericService(): \stdClass { return new \stdClass(); } -} \ No newline at end of file +} diff --git a/Tests/Functional/Issue48Test.php b/Tests/Functional/Issue48Test.php index e84eca2..b0ef955 100644 --- a/Tests/Functional/Issue48Test.php +++ b/Tests/Functional/Issue48Test.php @@ -20,6 +20,9 @@ class Issue48Test extends BaseTestCase { + /** + * @runInSeparateProcess + */ public function testCreatingMultipleKernelsInATest() { $kernelA = static::createKernel(array('debug' => false, 'config' => 'doctrine.yml')); diff --git a/Tests/Metadata/ClassMetadataTest.php b/Tests/Metadata/ClassMetadataTest.php index c8e6ca2..18cb89d 100644 --- a/Tests/Metadata/ClassMetadataTest.php +++ b/Tests/Metadata/ClassMetadataTest.php @@ -19,8 +19,9 @@ namespace JMS\DiExtraBundle\Tests\Metadata; use JMS\DiExtraBundle\Metadata\ClassMetadata; +use PHPUnit\Framework\TestCase; -class ClassMetadataTest extends \PHPUnit_Framework_TestCase +class ClassMetadataTest extends TestCase { public function testSerializeUnserialize() { diff --git a/Tests/Metadata/Driver/AnnotationDriverTest.php b/Tests/Metadata/Driver/AnnotationDriverTest.php index a598861..73c281a 100644 --- a/Tests/Metadata/Driver/AnnotationDriverTest.php +++ b/Tests/Metadata/Driver/AnnotationDriverTest.php @@ -21,8 +21,9 @@ use Doctrine\Common\Annotations\AnnotationReader; use JMS\DiExtraBundle\Metadata\DefaultNamingStrategy; use JMS\DiExtraBundle\Metadata\Driver\AnnotationDriver; +use PHPUnit\Framework\TestCase; -class AnnotationDriverTest extends \PHPUnit_Framework_TestCase +class AnnotationDriverTest extends TestCase { public function testFormType() { diff --git a/Tests/Metadata/Driver/ConfiguredControllerInjectionsDriverTest.php b/Tests/Metadata/Driver/ConfiguredControllerInjectionsDriverTest.php index a8fa4c6..72dc767 100644 --- a/Tests/Metadata/Driver/ConfiguredControllerInjectionsDriverTest.php +++ b/Tests/Metadata/Driver/ConfiguredControllerInjectionsDriverTest.php @@ -20,9 +20,10 @@ use JMS\DiExtraBundle\Metadata\ClassMetadata; use JMS\DiExtraBundle\Metadata\Driver\ConfiguredControllerInjectionsDriver; +use JMS\DiExtraBundle\Tests\BaseTestCase; use Symfony\Component\DependencyInjection\Reference; -class ConfiguredControllerInjectionsDriverTest extends \PHPUnit_Framework_TestCase +class ConfiguredControllerInjectionsDriverTest extends BaseTestCase { public function testIgnoresNonControllers() { @@ -73,7 +74,7 @@ public function testExplicitConfigurationWins() protected function setUp() { - $this->delegate = $this->getMock('Metadata\Driver\DriverInterface'); + $this->delegate = $this->createMock('Metadata\Driver\DriverInterface'); } private function delegateReturnsEmptyMetadata() diff --git a/Tests/PerformanceTest.php b/Tests/PerformanceTest.php index e624f63..785c38d 100644 --- a/Tests/PerformanceTest.php +++ b/Tests/PerformanceTest.php @@ -20,6 +20,7 @@ use JMS\DiExtraBundle\Finder\ServiceFinder; use JMS\SecurityExtraBundle\JMSSecurityExtraBundle; +use PHPUnit\Framework\TestCase; use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle; use Symfony\Bundle\AsseticBundle\AsseticBundle; use Symfony\Bundle\DoctrineBundle\DoctrineBundle; @@ -31,7 +32,7 @@ /** * @group performance */ -class PerformanceTest extends \PHPUnit_Framework_TestCase +class PerformanceTest extends TestCase { /** * @dataProvider getFinderMethods diff --git a/composer.json b/composer.json index 358ab1b..beeb94a 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "symfony/class-loader": "~2.3|~3.0", "symfony/yaml": "~2.3|~3.0", "symfony/browser-kit": "~2.3|~3.0", - "symfony/security-bundle": "~2.3", + "symfony/security-bundle": "~2.3|^3.0", "symfony/expression-language": "~2.6|~3.0", "symfony/twig-bundle": "~2.3|~3.0", "sensio/framework-extra-bundle": "~2.0|~3.0", @@ -36,8 +36,10 @@ "doctrine/doctrine-bundle": "~1.5", "doctrine/orm": "~2.3", "phpcollection/phpcollection": ">=0.2,<0.3-dev", - "symfony/phpunit-bridge": "~3.2", - "phpunit/phpunit": "^5.0.0" + "symfony/phpunit-bridge": "~3.3", + "phpunit/phpunit": "^4.8.35|^5.4.4|^6.0.0", + "symfony/asset": "~2.3|^3.3", + "symfony/templating": "~2.3|^3.3" }, "autoload": { "psr-4": { "JMS\\DiExtraBundle\\": "" }