Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #18529 [HttpKernel] Renamed the argument resolver tag (iltar)
This PR was merged into the 3.1-dev branch. Discussion ---------- [HttpKernel] Renamed the argument resolver tag | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | not if merged before 3.1 | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Changed as discussed several times: #18510 (comment), symfony/symfony-docs#6422 (comment). Commits ------- cd10057 Renamed argument resolver tag, added test
- Loading branch information
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...workBundle/Tests/DependencyInjection/Compiler/ControllerArgumentValueResolverPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; | ||
|
||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ControllerArgumentValueResolverPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\HttpKernel\Controller\ArgumentResolver; | ||
|
||
class ControllerArgumentValueResolverPassTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testServicesAreOrderedAccordingToPriority() | ||
{ | ||
$services = array( | ||
'n3' => array(array()), | ||
'n1' => array(array('priority' => 200)), | ||
'n2' => array(array('priority' => 100)), | ||
); | ||
|
||
$expected = array( | ||
new Reference('n1'), | ||
new Reference('n2'), | ||
new Reference('n3'), | ||
); | ||
|
||
$definition = new Definition(ArgumentResolver::class, array(null, array())); | ||
$container = new ContainerBuilder(); | ||
$container->setDefinition('argument_resolver', $definition); | ||
|
||
foreach ($services as $id => list($tag)) { | ||
$container->register($id)->addTag('controller.argument_value_resolver', $tag); | ||
} | ||
|
||
(new ControllerArgumentValueResolverPass())->process($container); | ||
$this->assertEquals($expected, $definition->getArgument(1)); | ||
} | ||
|
||
public function testReturningEmptyArrayWhenNoService() | ||
{ | ||
$definition = new Definition(ArgumentResolver::class, array(null, array())); | ||
$container = new ContainerBuilder(); | ||
$container->setDefinition('argument_resolver', $definition); | ||
|
||
(new ControllerArgumentValueResolverPass())->process($container); | ||
$this->assertEquals(array(), $definition->getArgument(1)); | ||
} | ||
|
||
public function testNoArgumentResolver() | ||
{ | ||
$container = new ContainerBuilder(); | ||
|
||
(new ControllerArgumentValueResolverPass())->process($container); | ||
} | ||
} |