From f6da5dde3e840eb0d46a84c82484957cdbcb827d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 12 Apr 2017 20:52:58 +0200 Subject: [PATCH] fix remaining risky tests --- .../Compiler/FormPassTest.php | 26 ++++++++++++++----- .../CheckCircularReferencesPassTest.php | 6 +++++ .../DependencyInjection/FormPassTest.php | 26 ++++++++++++++----- .../TraceableAccessDecisionManagerTest.php | 4 +-- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php index c0be018e23..9940594f1c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php @@ -166,22 +166,36 @@ class FormPassTest extends TestCase /** * @dataProvider privateTaggedServicesProvider */ - public function testPrivateTaggedServices($id, $tagName, array $tagAttributes = array()) + public function testPrivateTaggedServices($id, $tagName, $argumentKey, $expectedArgument, array $tagAttributes = array()) { - $container = $this->createContainerBuilder(); + $formPass = new FormPass(); + $container = new ContainerBuilder(); $container->setDefinition('form.extension', $this->createExtensionDefinition()); $container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, $tagAttributes); - $container->compile(); + $formPass->process($container); + + $this->assertEquals($expectedArgument, $container->getDefinition('form.extension')->getArgument($argumentKey)); } public function privateTaggedServicesProvider() { return array( - array('my.type', 'form.type'), - array('my.type_extension', 'form.type_extension', array('extended_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType')), - array('my.guesser', 'form.type_guesser'), + array( + 'my.type', + 'form.type', + 0, + new Reference('service_locator.c35554e29b2a3001b879847fc6a49848'), + ), + array( + 'my.type_extension', + 'form.type_extension', + 1, + array('Symfony\Component\Form\Extension\Core\Type\FormType' => new IteratorArgument(array(new Reference('my.type_extension')))), + array('extended_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType'), + ), + array('my.guesser', 'form.type_guesser', 2, new IteratorArgument(array(new Reference('my.guesser')))), ); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index 0305f16938..e8a526e722 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -126,6 +126,9 @@ class CheckCircularReferencesPassTest extends TestCase $container->register('b')->addArgument(new Reference('a')); $this->process($container); + + // just make sure that a lazily loaded service does not trigger a CircularReferenceException + $this->addToAssertionCount(1); } public function testProcessIgnoresIteratorArguments() @@ -135,6 +138,9 @@ class CheckCircularReferencesPassTest extends TestCase $container->register('b')->addArgument(new IteratorArgument(array(new Reference('a')))); $this->process($container); + + // just make sure that an IteratorArgument does not trigger a CircularReferenceException + $this->addToAssertionCount(1); } protected function process(ContainerBuilder $container) diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index d2be0db74c..30ef232d09 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -164,21 +164,35 @@ class FormPassTest extends TestCase /** * @dataProvider privateTaggedServicesProvider */ - public function testPrivateTaggedServices($id, $tagName, array $tagAttributes = array()) + public function testPrivateTaggedServices($id, $tagName, $argumentKey, $expectedArgument, array $tagAttributes = array()) { - $container = $this->createContainerBuilder(); + $formPass = new FormPass(); + $container = new ContainerBuilder(); $container->setDefinition('form.extension', $this->createExtensionDefinition()); $container->register($id, 'stdClass')->setPublic(false)->addTag($tagName, $tagAttributes); - $container->compile(); + $formPass->process($container); + + $this->assertEquals($expectedArgument, $container->getDefinition('form.extension')->getArgument($argumentKey)); } public function privateTaggedServicesProvider() { return array( - array('my.type', 'form.type'), - array('my.type_extension', 'form.type_extension', array('extended_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType')), - array('my.guesser', 'form.type_guesser'), + array( + 'my.type', + 'form.type', + 0, + new Reference('service_locator.c35554e29b2a3001b879847fc6a49848'), + ), + array( + 'my.type_extension', + 'form.type_extension', + 1, + array('Symfony\Component\Form\Extension\Core\Type\FormType' => new IteratorArgument(array(new Reference('my.type_extension')))), + array('extended_type' => 'Symfony\Component\Form\Extension\Core\Type\FormType'), + ), + array('my.guesser', 'form.type_guesser', 2, new IteratorArgument(array(new Reference('my.guesser')))), ); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php index 40e416e44f..b424b4bef9 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php @@ -47,8 +47,6 @@ class TraceableAccessDecisionManagerTest extends TestCase { $adm = new TraceableAccessDecisionManager(new AccessDecisionManager()); - if (!$adm instanceof DebugAccessDecisionManager) { - $this->fail('For BC, TraceableAccessDecisionManager must be an instance of DebugAccessDecisionManager'); - } + $this->assertInstanceOf(DebugAccessDecisionManager::class, $adm, 'For BC, TraceableAccessDecisionManager must be an instance of DebugAccessDecisionManager'); } }