‪TYPO3CMS  9.5
IfAuthenticatedViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 
25 class ‪IfAuthenticatedViewHelperTest extends ViewHelperBaseTestcase
26 {
30  protected ‪$viewHelper;
31 
32  protected function ‪setUp()
33  {
34  parent::setUp();
35  ‪$GLOBALS['BE_USER'] = new \stdClass();
36  $this->viewHelper = new ‪IfAuthenticatedViewHelper();
37  $this->injectDependenciesIntoViewHelper($this->viewHelper);
38  $this->viewHelper->initializeArguments();
39  }
40 
41  protected function ‪tearDown()
42  {
43  unset(‪$GLOBALS['BE_USER']);
44  }
45 
50  {
51  ‪$GLOBALS['BE_USER']->user = ['uid' => 1];
52 
53  $actualResult = $this->viewHelper->renderStatic(
54  ['then' => 'then child', 'else' => 'else child'],
55  function () {
56  },
57  $this->prophesize(RenderingContextInterface::class)->reveal()
58  );
59 
60  $this->assertEquals('then child', $actualResult);
61  }
62 
67  {
68  ‪$GLOBALS['BE_USER']->user = ['uid' => 0];
69 
70  $actualResult = $this->viewHelper->renderStatic(
71  ['then' => 'then child', 'else' => 'else child'],
72  function () {
73  },
74  $this->prophesize(RenderingContextInterface::class)->reveal()
75  );
76 
77  $this->assertEquals('else child', $actualResult);
78  }
79 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest
Definition: IfAuthenticatedViewHelperTest.php:26
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\$viewHelper
‪IfAuthenticatedViewHelper $viewHelper
Definition: IfAuthenticatedViewHelperTest.php:29
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Security\IfAuthenticatedViewHelper
Definition: IfAuthenticatedViewHelper.php:50
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security
Definition: IfAuthenticatedViewHelperTest.php:3
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\tearDown
‪tearDown()
Definition: IfAuthenticatedViewHelperTest.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\setUp
‪setUp()
Definition: IfAuthenticatedViewHelperTest.php:31
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\viewHelperRendersThenChildIfBeUserIsLoggedIn
‪viewHelperRendersThenChildIfBeUserIsLoggedIn()
Definition: IfAuthenticatedViewHelperTest.php:48
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\viewHelperRendersElseChildIfBeUserIsNotLoggedIn
‪viewHelperRendersElseChildIfBeUserIsNotLoggedIn()
Definition: IfAuthenticatedViewHelperTest.php:65