Skip to content

[SecurityBundle] Add AutowiringTypesTest #21522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
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;
Expand Down Expand Up @@ -66,21 +64,6 @@ public function testEventDispatcherAutowiring()
$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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;

Expand All @@ -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;
}

Expand All @@ -57,11 +54,6 @@ public function getDispatcher()
return $this->dispatcher;
}

public function getAccessDecisionManager()
{
return $this->accessDecisionManager;
}

public function getCachePool()
{
return $this->cachePool;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,3 @@ services:
framework:
templating:
engines: ['php']
security:
providers:
dummy:
memory: ~
firewalls:
dummy:
security: false
5 changes: 2 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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
{
}
Original file line number Diff line number Diff line change
@@ -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(),
);
Original file line number Diff line number Diff line change
@@ -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