‪TYPO3CMS  9.5
BackendUserControllerTest.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 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪BackendUserControllerTest extends UnitTestCase
26 {
30  protected ‪$subject;
31 
32  protected function ‪setUp()
33  {
34  ‪$GLOBALS['BE_USER'] = $this->createMock(BackendUserAuthentication::class);
35  ‪$GLOBALS['BE_USER']->uc = [
36  'recentSwitchedToUsers' => []
37  ];
38 
39  $this->subject = $this->getAccessibleMock(BackendUserController::class, ['dummy'], [], '', false);
40  }
41 
46  {
47  $items = range(1, ‪BackendUserController::RECENT_USERS_LIMIT + 5);
48  $expected = array_reverse(array_slice($items, -‪BackendUserController::RECENT_USERS_LIMIT));
49  foreach ($items as $id) {
50  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', $id);
51  }
52 
53  static::assertCount(‪BackendUserController::RECENT_USERS_LIMIT, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
54  static::assertSame($expected, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
55  }
56 
61  {
62  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', 100);
63  ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers'] = $this->subject->_call('generateListOfMostRecentSwitchedUsers', 100);
64 
65  static::assertCount(1, ‪$GLOBALS['BE_USER']->uc['recentSwitchedToUsers']);
66  }
67 }
‪TYPO3\CMS\Beuser\Controller\BackendUserController\RECENT_USERS_LIMIT
‪const RECENT_USERS_LIMIT
Definition: BackendUserController.php:43
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\setUp
‪setUp()
Definition: BackendUserControllerTest.php:31
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest
Definition: BackendUserControllerTest.php:26
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\$subject
‪BackendUserController PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $subject
Definition: BackendUserControllerTest.php:29
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\listOfLatestSwitchedUsersDoesNotContainTheSameUserTwice
‪listOfLatestSwitchedUsersDoesNotContainTheSameUserTwice()
Definition: BackendUserControllerTest.php:59
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Beuser\Tests\Unit\Controller
Definition: BackendUserControllerTest.php:3
‪TYPO3\CMS\Beuser\Tests\Unit\Controller\BackendUserControllerTest\generateListOfLatestSwitchedUsersReturnsCorrectAmountAndOrder
‪generateListOfLatestSwitchedUsersReturnsCorrectAmountAndOrder()
Definition: BackendUserControllerTest.php:44
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Beuser\Controller\BackendUserController
Definition: BackendUserController.php:32