This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix empty message for security annotation/attribute
- Loading branch information
1 parent
5e7f568
commit 019d9f5
Showing
2 changed files
with
55 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?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 Sensio\Bundle\FrameworkExtraBundle\Tests\Configuration; | ||
|
||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||
|
||
class SecurityTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testEmptyConstruct() | ||
{ | ||
$security = new Security([]); | ||
$this->assertEquals('Access denied.', $security->getMessage()); | ||
$this->assertNull($security->getStatusCode()); | ||
$this->assertNull($security->getExpression()); | ||
$this->assertEquals('security', $security->getAliasName()); | ||
$this->assertTrue($security->allowArray()); | ||
} | ||
|
||
public function testSettersViaConstruct() | ||
{ | ||
$security = new Security("is_granted('foo')", 'Not allowed', 403); | ||
$this->assertEquals('Not allowed', $security->getMessage()); | ||
$this->assertEquals(403, $security->getStatusCode()); | ||
$this->assertEquals("is_granted('foo')", $security->getExpression()); | ||
} | ||
|
||
public function testSetters() | ||
{ | ||
$security = new Security("is_granted('foo')", 'Not allowed', 403); | ||
$security->setExpression("is_granted('bar')"); | ||
$security->setMessage('Disallowed'); | ||
$security->setStatusCode(404); | ||
$this->assertEquals('Disallowed', $security->getMessage()); | ||
$this->assertEquals(404, $security->getStatusCode()); | ||
$this->assertEquals("is_granted('bar')", $security->getExpression()); | ||
} | ||
|
||
public function testDataWinsOverExplicitParam() | ||
{ | ||
$security = new Security(['expression' => "is_granted('foo')", 'message' => 'Not allowed', 'statusCode' => 403], 'Disallowed', 404); | ||
$this->assertEquals('Not allowed', $security->getMessage()); | ||
$this->assertEquals(403, $security->getStatusCode()); | ||
$this->assertEquals("is_granted('foo')", $security->getExpression()); | ||
} | ||
} |