minor #22404 fix remaining risky tests (xabbuh)

This PR was merged into the 3.3-dev branch.

Discussion
----------

fix remaining risky tests

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

f6da5dde3e fix remaining risky tests
This commit is contained in:
Fabien Potencier 2017-04-12 12:07:46 -07:00
commit 6fe7b61372
4 changed files with 47 additions and 15 deletions

View File

@ -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')))),
);
}

View File

@ -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)

View File

@ -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')))),
);
}

View File

@ -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');
}
}