[FEATURE] New option to disable the age display of dates per field by TCA
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Controller / LoginControllerTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Controller\LoginController;
18 use TYPO3\CMS\Backend\LoginProvider\UsernamePasswordLoginProvider;
19 use TYPO3\CMS\Core\Tests\UnitTestCase;
20
21 /**
22 * Class LoginControllerTest
23 */
24 class LoginControllerTest extends UnitTestCase {
25
26 /**
27 * @var LoginController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
28 */
29 protected $loginControllerMock;
30
31 /**
32 * @throws \InvalidArgumentException
33 */
34 protected function setUp() {
35 $this->loginControllerMock = $this->getAccessibleMock(LoginController::class, ['dummy'], [], '', FALSE);
36 }
37
38 /**
39 * @test
40 * @expectedException \RuntimeException
41 * @expectedExceptionCode 1433417281
42 */
43 public function validateAndSortLoginProvidersDetectsMissingProviderConfiguration() {
44 unset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders']);
45 $this->loginControllerMock->_call('validateAndSortLoginProviders');
46 }
47
48 /**
49 * @test
50 * @expectedException \RuntimeException
51 * @expectedExceptionCode 1433417281
52 */
53 public function validateAndSortLoginProvidersDetectsNonArrayProviderConfiguration() {
54 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = 'foo';
55 $this->loginControllerMock->_call('validateAndSortLoginProviders');
56 }
57
58 /**
59 * @test
60 * @expectedException \RuntimeException
61 * @expectedExceptionCode 1433417281
62 */
63 public function validateAndSortLoginProvidersDetectsIfNoProviderIsRegistered() {
64 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [];
65 $this->loginControllerMock->_call('validateAndSortLoginProviders');
66 }
67
68 /**
69 * @test
70 * @expectedException \RuntimeException
71 * @expectedExceptionCode 1433416043
72 */
73 public function validateAndSortLoginProvidersDetectsMissingConfigurationForProvider() {
74 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
75 1433419736 => []
76 ];
77 $this->loginControllerMock->_call('validateAndSortLoginProviders');
78 }
79
80 /**
81 * @test
82 * @expectedException \RuntimeException
83 * @expectedExceptionCode 1433416043
84 */
85 public function validateAndSortLoginProvidersDetectsWrongProvider() {
86 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
87 1433419736 => [
88 'provider' => \stdClass::class
89 ]
90 ];
91 $this->loginControllerMock->_call('validateAndSortLoginProviders');
92 }
93
94 /**
95 * @test
96 * @expectedException \RuntimeException
97 * @expectedExceptionCode 1433416044
98 */
99 public function validateAndSortLoginProvidersDetectsMissingLabel() {
100 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
101 1433419736 => [
102 'provider' => UsernamePasswordLoginProvider::class,
103 'sorting' => 30,
104 'icon-class' => 'foo'
105 ]
106 ];
107 $this->loginControllerMock->_call('validateAndSortLoginProviders');
108 }
109
110 /**
111 * @test
112 * @expectedException \RuntimeException
113 * @expectedExceptionCode 1433416045
114 */
115 public function validateAndSortLoginProvidersDetectsMissingIconClass() {
116 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
117 1433419736 => [
118 'provider' => UsernamePasswordLoginProvider::class,
119 'sorting' => 30,
120 'label' => 'foo'
121 ]
122 ];
123 $this->loginControllerMock->_call('validateAndSortLoginProviders');
124 }
125
126 /**
127 * @test
128 * @expectedException \RuntimeException
129 * @expectedExceptionCode 1433416046
130 */
131 public function validateAndSortLoginProvidersDetectsMissingSorting() {
132 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
133 1433419736 => [
134 'provider' => UsernamePasswordLoginProvider::class,
135 'label' => 'foo',
136 'icon-class' => 'foo'
137 ]
138 ];
139 $this->loginControllerMock->_call('validateAndSortLoginProviders');
140 }
141
142 }