‪TYPO3CMS  10.4
BackendUserControllerTest.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 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪BackendUserControllerTest extends UnitTestCase
28 {
32  protected ‪$subject;
33 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  ‪$GLOBALS['BE_USER'] = $this->createMock(BackendUserAuthentication::class);
38  ‪$GLOBALS['BE_USER']->uc = [
39  'recentSwitchedToUsers' => []
40  ];
41 
42  $this->subject = $this->getAccessibleMock(BackendUserController::class, ['dummy'], [], '', false);
43  }
44 
49  {
50  $items = range(1, ‪BackendUserController::RECENT_USERS_LIMIT + 5);
51  $expected = array_reverse(array_slice($items, -‪BackendUserController::RECENT_USERS_LIMIT));
52  foreach ($items as $id) {
53  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', $id);
54  }
55 
56  self::assertCount(‪BackendUserController::RECENT_USERS_LIMIT, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
57  self::assertSame($expected, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
58  }
59 
64  {
65  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', 100);
66  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', 100);
67 
68  self::assertCount(1, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
69  }
70 }
‪TYPO3\CMS\Beuser\Controller\BackendUserController\RECENT_USERS_LIMIT
‪const RECENT_USERS_LIMIT
Definition: BackendUserController.php:52
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\setUp
‪setUp()
Definition: BackendUserControllerTest.php:33
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest
Definition: BackendUserControllerTest.php:28
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\listOfLatestSwitchedUsersDoesNotContainTheSameUserTwice
‪listOfLatestSwitchedUsersDoesNotContainTheSameUserTwice()
Definition: BackendUserControllerTest.php:62
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\$subject
‪BackendUserController PHPUnit Framework MockObject MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $subject
Definition: BackendUserControllerTest.php:31
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Beuser\Tests\Unit\Controller
Definition: BackendUserControllerTest.php:18
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\generateListOfLatestSwitchedUsersReturnsCorrectAmountAndOrder
‪generateListOfLatestSwitchedUsersReturnsCorrectAmountAndOrder()
Definition: BackendUserControllerTest.php:47
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Beuser\Controller\BackendUserController
Definition: BackendUserController.php:48