Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed6a2ed

Browse files
committed
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 | #21517 (comment) | License | MIT Commits ------- d1001d4 [SecurityBundle] Add AutowiringTypesTest
2 parents 7c5dcfc + d1001d4 commit ed6a2ed

File tree

10 files changed

+118
-38
lines changed

10 files changed

+118
-38
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
1616
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
17-
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
18-
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
1917
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
2018
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
2119
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
@@ -66,21 +64,6 @@ public function testEventDispatcherAutowiring()
6664
$this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled');
6765
}
6866

69-
public function testAccessDecisionManagerAutowiring()
70-
{
71-
static::bootKernel(array('debug' => false));
72-
$container = static::$kernel->getContainer();
73-
74-
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
75-
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');
76-
77-
static::bootKernel(array('debug' => true));
78-
$container = static::$kernel->getContainer();
79-
80-
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
81-
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
82-
}
83-
8467
public function testCacheAutowiring()
8568
{
8669
static::bootKernel();

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\Common\Annotations\Reader;
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
17-
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
1817
use Symfony\Component\Templating\EngineInterface;
1918
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2019

@@ -24,16 +23,14 @@ class AutowiredServices
2423
private $frameworkBundleEngine;
2524
private $engine;
2625
private $dispatcher;
27-
private $accessDecisionManager;
2826
private $cachePool;
2927

30-
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, AccessDecisionManagerInterface $accessDecisionManager, CacheItemPoolInterface $cachePool)
28+
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool)
3129
{
3230
$this->annotationReader = $annotationReader;
3331
$this->frameworkBundleEngine = $frameworkBundleEngine;
3432
$this->engine = $engine;
3533
$this->dispatcher = $dispatcher;
36-
$this->accessDecisionManager = $accessDecisionManager;
3734
$this->cachePool = $cachePool;
3835
}
3936

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

60-
public function getAccessDecisionManager()
61-
{
62-
return $this->accessDecisionManager;
63-
}
64-
6557
public function getCachePool()
6658
{
6759
return $this->cachePool;

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
1313
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
14-
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1514

1615
return array(
1716
new FrameworkBundle(),
18-
new SecurityBundle(),
1917
new TestBundle(),
2018
);

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,3 @@ services:
88
framework:
99
templating:
1010
engines: ['php']
11-
security:
12-
providers:
13-
dummy:
14-
memory: ~
15-
firewalls:
16-
dummy:
17-
security: false

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"symfony/css-selector": "~2.8|~3.0",
4141
"symfony/dom-crawler": "~2.8|~3.0",
4242
"symfony/polyfill-intl-icu": "~1.0",
43-
"symfony/security": "~3.3",
43+
"symfony/security": "~2.8|~3.0",
4444
"symfony/form": "~2.8.16|~3.1.9|^3.2.2",
4545
"symfony/expression-language": "~2.8|~3.0",
4646
"symfony/process": "~2.8|~3.0",
@@ -55,8 +55,7 @@
5555
"doctrine/annotations": "~1.0",
5656
"phpdocumentor/reflection-docblock": "^3.0",
5757
"twig/twig": "~1.26|~2.0",
58-
"sensio/framework-extra-bundle": "^3.0.2",
59-
"symfony/security-bundle": "~3.3"
58+
"sensio/framework-extra-bundle": "^3.0.2"
6059
},
6160
"conflict": {
6261
"phpdocumentor/reflection-docblock": "<3.0",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
13+
14+
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
15+
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
16+
17+
class AutowiringTypesTest extends WebTestCase
18+
{
19+
public function testAccessDecisionManagerAutowiring()
20+
{
21+
static::bootKernel(array('debug' => false));
22+
$container = static::$kernel->getContainer();
23+
24+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
25+
$this->assertInstanceOf(AccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The security.access.decision_manager service should be injected in debug mode');
26+
27+
static::bootKernel(array('debug' => true));
28+
$container = static::$kernel->getContainer();
29+
30+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
31+
$this->assertInstanceOf(TraceableAccessDecisionManager::class, $autowiredServices->getAccessDecisionManager(), 'The debug.security.access.decision_manager service should be injected in non-debug mode');
32+
}
33+
34+
protected static function createKernel(array $options = array())
35+
{
36+
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);
37+
}
38+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle;
13+
14+
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
15+
16+
class AutowiredServices
17+
{
18+
private $accessDecisionManager;
19+
20+
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
21+
{
22+
$this->accessDecisionManager = $accessDecisionManager;
23+
}
24+
25+
public function getAccessDecisionManager()
26+
{
27+
return $this->accessDecisionManager;
28+
}
29+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class AutowiringBundle extends Bundle
17+
{
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
return array(
13+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14+
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
15+
new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiringBundle(),
16+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
imports:
2+
- { resource: ../config/framework.yml }
3+
4+
services:
5+
test.autowiring_types.autowired_services:
6+
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AutowiringBundle\AutowiredServices
7+
autowire: true
8+
security:
9+
providers:
10+
dummy:
11+
memory: ~
12+
firewalls:
13+
dummy:
14+
security: false

0 commit comments

Comments
 (0)