‪TYPO3CMS  10.4
IfAuthenticatedViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
21 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 
27 class ‪IfAuthenticatedViewHelperTest extends ViewHelperBaseTestcase
28 {
32  protected ‪$viewHelper;
33 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  ‪$GLOBALS['BE_USER'] = new \stdClass();
38  $this->viewHelper = new ‪IfAuthenticatedViewHelper();
39  $this->injectDependenciesIntoViewHelper($this->viewHelper);
40  $this->viewHelper->initializeArguments();
41  }
42 
43  protected function ‪tearDown(): void
44  {
45  unset(‪$GLOBALS['BE_USER']);
46  parent::tearDown();
47  }
48 
53  {
54  ‪$GLOBALS['BE_USER']->user = ['uid' => 1];
55 
56  $actualResult = $this->viewHelper->renderStatic(
57  ['then' => 'then child', 'else' => 'else child'],
58  function () {
59  },
60  $this->prophesize(RenderingContextInterface::class)->reveal()
61  );
62 
63  self::assertEquals('then child', $actualResult);
64  }
65 
70  {
71  ‪$GLOBALS['BE_USER']->user = ['uid' => 0];
72 
73  $actualResult = $this->viewHelper->renderStatic(
74  ['then' => 'then child', 'else' => 'else child'],
75  function () {
76  },
77  $this->prophesize(RenderingContextInterface::class)->reveal()
78  );
79 
80  self::assertEquals('else child', $actualResult);
81  }
82 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest
Definition: IfAuthenticatedViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\$viewHelper
‪IfAuthenticatedViewHelper $viewHelper
Definition: IfAuthenticatedViewHelperTest.php:31
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Security\IfAuthenticatedViewHelper
Definition: IfAuthenticatedViewHelper.php:51
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security
Definition: IfAuthenticatedViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\tearDown
‪tearDown()
Definition: IfAuthenticatedViewHelperTest.php:42
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\setUp
‪setUp()
Definition: IfAuthenticatedViewHelperTest.php:33
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Be\Security\IfAuthenticatedViewHelperTest\viewHelperRendersThenChildIfBeUserIsLoggedIn
‪viewHelperRendersThenChildIfBeUserIsLoggedIn()
Definition: IfAuthenticatedViewHelperTest.php:51
‪$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:68