TYPO3 CMS  TYPO3_8-7
LoginControllerTest.php
Go to the documentation of this file.
1 <?php
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 
19 
23 class LoginControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
29 
33  protected function setUp()
34  {
35  $this->loginControllerMock = $this->getAccessibleMock(LoginController::class, ['dummy'], [], '', false);
36  }
37 
42  {
43  $this->expectException(\RuntimeException::class);
44  $this->expectExceptionCode(1433417281);
45  unset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders']);
46  $this->loginControllerMock->_call('validateAndSortLoginProviders');
47  }
48 
53  {
54  $this->expectException(\RuntimeException::class);
55  $this->expectExceptionCode(1433417281);
56  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = 'foo';
57  $this->loginControllerMock->_call('validateAndSortLoginProviders');
58  }
59 
64  {
65  $this->expectException(\RuntimeException::class);
66  $this->expectExceptionCode(1433417281);
67  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [];
68  $this->loginControllerMock->_call('validateAndSortLoginProviders');
69  }
70 
75  {
76  $this->expectException(\RuntimeException::class);
77  $this->expectExceptionCode(1433416043);
78  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
79  1433419736 => []
80  ];
81  $this->loginControllerMock->_call('validateAndSortLoginProviders');
82  }
83 
88  {
89  $this->expectException(\RuntimeException::class);
90  $this->expectExceptionCode(1460977275);
91  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
92  1433419736 => [
93  'provider' => \stdClass::class
94  ]
95  ];
96  $this->loginControllerMock->_call('validateAndSortLoginProviders');
97  }
98 
103  {
104  $this->expectException(\RuntimeException::class);
105  $this->expectExceptionCode(1433416044);
106  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
107  1433419736 => [
108  'provider' => UsernamePasswordLoginProvider::class,
109  'sorting' => 30,
110  'icon-class' => 'foo'
111  ]
112  ];
113  $this->loginControllerMock->_call('validateAndSortLoginProviders');
114  }
115 
120  {
121  $this->expectException(\RuntimeException::class);
122  $this->expectExceptionCode(1433416045);
123  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
124  1433419736 => [
125  'provider' => UsernamePasswordLoginProvider::class,
126  'sorting' => 30,
127  'label' => 'foo'
128  ]
129  ];
130  $this->loginControllerMock->_call('validateAndSortLoginProviders');
131  }
132 
137  {
138  $this->expectException(\RuntimeException::class);
139  $this->expectExceptionCode(1433416046);
140  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['loginProviders'] = [
141  1433419736 => [
142  'provider' => UsernamePasswordLoginProvider::class,
143  'label' => 'foo',
144  'icon-class' => 'foo'
145  ]
146  ];
147  $this->loginControllerMock->_call('validateAndSortLoginProviders');
148  }
149 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']