summaryrefslogtreecommitdiffstats
path: root/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2017-01-03 10:52:33 +0100
committerNicolas Grekas <nicolas.grekas@gmail.com>2017-01-03 10:52:33 +0100
commit43d87514e9ef2f05c6b70f5e9fa57af9eb74bc12 (patch)
treed97f5135e5bea364fea008b4ce13b20e5d4f8e23 /Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php
parentd8ef1285ab7a57971090fb70449a4098f2cb7ac9 (diff)
parent866bd6fe7d3b62a0d1c671a2b340aee73241a095 (diff)
downloadsymfony-security-43d87514e9ef2f05c6b70f5e9fa57af9eb74bc12.zip
symfony-security-43d87514e9ef2f05c6b70f5e9fa57af9eb74bc12.tar.gz
symfony-security-43d87514e9ef2f05c6b70f5e9fa57af9eb74bc12.tar.bz2
minor #21088 Rename DebugAccessDecisionManager to TraceableAccessDecisionManager (Jean85)
This PR was squashed before being merged into the 3.3-dev branch (closes #21088). Discussion ---------- Rename DebugAccessDecisionManager to TraceableAccessDecisionManager | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21085 | License | MIT [EDIT] No longer WIP, test passing. Also, test added to preserve BC with the SecurityBundle. Commits ------- c5e0e59 Rename DebugAccessDecisionManager to TraceableAccessDecisionManager
Diffstat (limited to 'Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php')
-rw-r--r--Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php b/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php
new file mode 100644
index 0000000..1c50f58
--- /dev/null
+++ b/Core/Tests/Authorization/TraceableAccessDecisionManagerTest.php
@@ -0,0 +1,53 @@
+<?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\Component\Security\Core\Tests\Authorization;
+
+use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
+use Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager;
+use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+
+class TraceableAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider provideObjectsAndLogs
+ */
+ public function testDecideLog($expectedLog, $object)
+ {
+ $adm = new TraceableAccessDecisionManager(new AccessDecisionManager());
+ $adm->decide($this->getMockBuilder(TokenInterface::class)->getMock(), array('ATTRIBUTE_1'), $object);
+
+ $this->assertSame($expectedLog, $adm->getDecisionLog());
+ }
+
+ public function provideObjectsAndLogs()
+ {
+ $object = new \stdClass();
+
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => null, 'result' => false)), null);
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => true, 'result' => false)), true);
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'jolie string', 'result' => false)), 'jolie string');
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 12345, 'result' => false)), 12345);
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => $x = fopen(__FILE__, 'r'), 'result' => false)), $x);
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => $x = array(), 'result' => false)), $x);
+ yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => $object, 'result' => false)), $object);
+ }
+
+ public function testDebugAccessDecisionManagerAliasExistsForBC()
+ {
+ $adm = new TraceableAccessDecisionManager(new AccessDecisionManager());
+
+ if (!$adm instanceof DebugAccessDecisionManager) {
+ $this->fail('For BC, TraceableAccessDecisionManager must be an instance of DebugAccessDecisionManager');
+ }
+ }
+}