‪TYPO3CMS  11.5
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 
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 class ‪IfAuthenticatedViewHelperTest extends FunctionalTestCase
28 {
32  protected ‪$initializeDatabase = false;
33 
38  {
39  $user = new ‪FrontendUserAuthentication();
40  $user->user['uid'] = 13;
41  $context = new ‪Context();
42  $context->setAspect('frontend.user', new ‪UserAspect($user));
43  GeneralUtility::setSingletonInstance(Context::class, $context);
44 
45  $view = new ‪StandaloneView();
46  $view->setTemplateSource('<f:security.ifAuthenticated><f:then>then child</f:then><f:else>else child</f:else></f:security.ifAuthenticated>');
47  self::assertEquals('then child', $view->render());
48  }
49 
54  {
55  $context = new ‪Context();
56  $context->setAspect('frontend.user', new ‪UserAspect());
57  GeneralUtility::setSingletonInstance(Context::class, $context);
58 
59  $view = new ‪StandaloneView();
60  $view->setTemplateSource('<f:security.ifAuthenticated><f:then>then child</f:then><f:else>else child</f:else></f:security.ifAuthenticated>');
61  self::assertEquals('else child', $view->render());
62  }
63 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Security\IfAuthenticatedViewHelperTest\viewHelperRendersElseChildIfFeUserIsNotLoggedIn
‪viewHelperRendersElseChildIfFeUserIsNotLoggedIn()
Definition: IfAuthenticatedViewHelperTest.php:52
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Security\IfAuthenticatedViewHelperTest\viewHelperRendersThenChildIfFeUserIsLoggedIn
‪viewHelperRendersThenChildIfFeUserIsLoggedIn()
Definition: IfAuthenticatedViewHelperTest.php:36
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Security\IfAuthenticatedViewHelperTest
Definition: IfAuthenticatedViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Security
Definition: IfAuthenticatedViewHelperTest.php:18
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Security\IfAuthenticatedViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: IfAuthenticatedViewHelperTest.php:31
‪TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
Definition: FrontendUserAuthentication.php:32
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:37