minor #21522 [SecurityBundle] Add AutowiringTypesTest (chalasr)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[SecurityBundle] Add AutowiringTypesTest
| Q | A
| ------------- | ---
| Branch? | master
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/21517#discussion_r99351908
| License | MIT
Commits
-------
d1001d4bac
[SecurityBundle] Add AutowiringTypesTest
This commit is contained in:
commit
ed6a2ed3eb
@ -14,8 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
||||
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
@ -66,21 +64,6 @@ class AutowiringTypesTest extends WebTestCase
|
||||
$this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled');
|
||||
}
|
||||
|
||||
public function testAccessDecisionManagerAutowiring()
|
||||
{
|
||||
static::bootKernel(array('debug' => false));
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');
|
||||
|
||||
static::bootKernel(array('debug' => true));
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
|
||||
}
|
||||
|
||||
public function testCacheAutowiring()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
@ -14,7 +14,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Auto
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
@ -24,16 +23,14 @@ class AutowiredServices
|
||||
private $frameworkBundleEngine;
|
||||
private $engine;
|
||||
private $dispatcher;
|
||||
private $accessDecisionManager;
|
||||
private $cachePool;
|
||||
|
||||
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, AccessDecisionManagerInterface $accessDecisionManager, CacheItemPoolInterface $cachePool)
|
||||
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool)
|
||||
{
|
||||
$this->annotationReader = $annotationReader;
|
||||
$this->frameworkBundleEngine = $frameworkBundleEngine;
|
||||
$this->engine = $engine;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
$this->cachePool = $cachePool;
|
||||
}
|
||||
|
||||
@ -57,11 +54,6 @@ class AutowiredServices
|
||||
return $this->dispatcher;
|
||||
}
|
||||
|
||||
public function getAccessDecisionManager()
|
||||
{
|
||||
return $this->accessDecisionManager;
|
||||
}
|
||||
|
||||
public function getCachePool()
|
||||
{
|
||||
return $this->cachePool;
|
||||
|
@ -11,10 +11,8 @@
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||
|
||||
return array(
|
||||
new FrameworkBundle(),
|
||||
new SecurityBundle(),
|
||||
new TestBundle(),
|
||||
);
|
||||
|
@ -8,10 +8,3 @@ services:
|
||||
framework:
|
||||
templating:
|
||||
engines: ['php']
|
||||
security:
|
||||
providers:
|
||||
dummy:
|
||||
memory: ~
|
||||
firewalls:
|
||||
dummy:
|
||||
security: false
|
||||
|
@ -40,7 +40,7 @@
|
||||
"symfony/css-selector": "~2.8|~3.0",
|
||||
"symfony/dom-crawler": "~2.8|~3.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
"symfony/security": "~3.3",
|
||||
"symfony/security": "~2.8|~3.0",
|
||||
"symfony/form": "~2.8.16|~3.1.9|^3.2.2",
|
||||
"symfony/expression-language": "~2.8|~3.0",
|
||||
"symfony/process": "~2.8|~3.0",
|
||||
@ -55,8 +55,7 @@
|
||||
"doctrine/annotations": "~1.0",
|
||||
"phpdocumentor/reflection-docblock": "^3.0",
|
||||
"twig/twig": "~1.26|~2.0",
|
||||
"sensio/framework-extra-bundle": "^3.0.2",
|
||||
"symfony/security-bundle": "~3.3"
|
||||
"sensio/framework-extra-bundle": "^3.0.2"
|
||||
},
|
||||
"conflict": {
|
||||
"phpdocumentor/reflection-docblock": "<3.0",
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?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\SecurityBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
||||
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
|
||||
|
||||
class AutowiringTypesTest extends WebTestCase
|
||||
{
|
||||
public function testAccessDecisionManagerAutowiring()
|
||||
{
|
||||
static::bootKernel(array('debug' => false));
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');
|
||||
|
||||
static::bootKernel(array('debug' => true));
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = array())
|
||||
{
|
||||
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?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\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle;
|
||||
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||
|
||||
class AutowiredServices
|
||||
{
|
||||
private $accessDecisionManager;
|
||||
|
||||
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
|
||||
{
|
||||
$this->accessDecisionManager = $accessDecisionManager;
|
||||
}
|
||||
|
||||
public function getAccessDecisionManager()
|
||||
{
|
||||
return $this->accessDecisionManager;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?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\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class AutowiringBundle extends Bundle
|
||||
{
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
return array(
|
||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||
new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiringBundle(),
|
||||
);
|
@ -0,0 +1,14 @@
|
||||
imports:
|
||||
- { resource: ../config/framework.yml }
|
||||
|
||||
services:
|
||||
test.autowiring_types.autowired_services:
|
||||
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiredServices
|
||||
autowire: true
|
||||
security:
|
||||
providers:
|
||||
dummy:
|
||||
memory: ~
|
||||
firewalls:
|
||||
dummy:
|
||||
security: false
|
Reference in New Issue
Block a user