Skip to content

Commit

Permalink
[TASK] Add a test case for v:security.deny
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Jan 26, 2023
1 parent 3b875a2 commit 71db290
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 0 additions & 1 deletion Classes/ViewHelpers/Security/DenyViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class DenyViewHelper extends AbstractSecurityViewHelper
{

/**
* Overridden condition evaluation - full negation of verdict
*
Expand Down
26 changes: 23 additions & 3 deletions Tests/Unit/ViewHelpers/Security/DenyViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@

use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTestCase;
use FluidTYPO3\Vhs\ViewHelpers\Security\DenyViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

/**
* Class DenyViewHelperTest
*/
class DenyViewHelperTest extends AbstractViewHelperTestCase
{
public function testInvertsDecision(): void
{
$GLOBALS['BE_USER'] = (object) [
'user' => ['uid' => 1],
];
$viewHelper = $this->getMockBuilder(DenyViewHelper::class)
->setMethods(['dummy'])
->disableOriginalConstructor()
->getMock();
$arguments = $this->buildViewHelperArguments($viewHelper, ['anyBackendUser' => true]);
$this->createViewHelperNode($viewHelper, $arguments, [$this->createNode('Text', 'protected')]);
$viewHelper->setArguments($arguments);

$viewHelper->setRenderingContext(
$this->getMockBuilder(RenderingContextInterface::class)->getMockForAbstractClass()
);

GeneralUtility::addInstance(get_class($viewHelper), $viewHelper);
self::assertSame('', $viewHelper->render());
}
}

0 comments on commit 71db290

Please sign in to comment.