26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
52 protected function setUp()
54 $this->loginControllerMock = $this->getAccessibleMock(LoginController::class, [
'dummy'], [],
'',
false);
62 $this->expectException(\RuntimeException::class);
63 $this->expectExceptionCode(1433417281);
64 unset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders']);
65 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
73 $this->expectException(\RuntimeException::class);
74 $this->expectExceptionCode(1433417281);
75 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] =
'foo';
76 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
84 $this->expectException(\RuntimeException::class);
85 $this->expectExceptionCode(1433417281);
86 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [];
87 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
95 $this->expectException(\RuntimeException::class);
96 $this->expectExceptionCode(1433416043);
97 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [
100 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
108 $this->expectException(\RuntimeException::class);
109 $this->expectExceptionCode(1460977275);
110 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [
112 'provider' => \stdClass::class,
115 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
123 $this->expectException(\RuntimeException::class);
124 $this->expectExceptionCode(1433416044);
125 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [
127 'provider' => UsernamePasswordLoginProvider::class,
129 'icon-class' =>
'foo',
132 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
140 $this->expectException(\RuntimeException::class);
141 $this->expectExceptionCode(1433416045);
142 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [
144 'provider' => UsernamePasswordLoginProvider::class,
149 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
157 $this->expectException(\RuntimeException::class);
158 $this->expectExceptionCode(1433416046);
159 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'backend'][
'loginProviders'] = [
161 'provider' => UsernamePasswordLoginProvider::class,
163 'icon-class' =>
'foo',
166 $this->loginControllerMock->_call(
'validateAndSortLoginProviders');
174 $GLOBALS[
'LANG'] = ($this->prophesize(LanguageService::class))->reveal();
175 $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class);
176 $authenticationProphecy->getTSConfig()->willReturn([
179 'redirectToURL' =>
'http://example.com'
183 $authenticationProphecy->writeUC()->willReturn();
184 $authenticationProphecy->getSessionData(
'formProtectionSessionToken')->willReturn(
'foo');
185 $GLOBALS[
'BE_USER'] = $authenticationProphecy->reveal();
188 $this->loginControllerMock = $this->getAccessibleMock(
189 LoginController::class,
190 [
'isLoginInProgress',
'redirectToUrl'],
197 $this->loginControllerMock->method(
'isLoginInProgress')->willReturn(
true);
198 $this->loginControllerMock->_set(
'loginRefresh',
false);
200 $this->loginControllerMock->expects($this->once())->method(
'redirectToUrl');
201 $this->loginControllerMock->_call(
'checkRedirect', $this->prophesize(ServerRequest::class)->reveal());
209 $GLOBALS[
'LANG'] = $this->prophesize(LanguageService::class)->reveal();
210 $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class);
211 $authenticationProphecy->getTSConfig()->willReturn([
214 'redirectToURL' =>
'http://example.com'
218 $authenticationProphecy->writeUC()->willReturn();
220 $GLOBALS[
'BE_USER'] = $authenticationProphecy->reveal();
221 $documentTemplateProphecy = $this->prophesize(DocumentTemplate::class);
222 $GLOBALS[
'TBE_TEMPLATE'] = $documentTemplateProphecy->reveal();
224 $this->loginControllerMock = $this->getAccessibleMock(
225 LoginController::class,
226 [
'isLoginInProgress',
'redirectToUrl'],
233 $this->loginControllerMock->method(
'isLoginInProgress')->willReturn(
false);
234 $this->loginControllerMock->_set(
'loginRefresh',
true);
236 $this->loginControllerMock->_call(
'checkRedirect', $this->prophesize(ServerRequest::class)->reveal());
238 self::assertContains(
'window.opener.TYPO3.LoginRefresh.startTask();', $documentTemplateProphecy->JScode);
246 $GLOBALS[
'LANG'] = $this->prophesize(LanguageService::class)->reveal();
247 $authenticationProphecy = $this->prophesize(BackendUserAuthentication::class);
248 $authenticationProphecy->getTSConfig()->willReturn([
251 'redirectToURL' =>
'http://example.com'
255 $authenticationProphecy->writeUC()->willReturn();
256 $GLOBALS[
'BE_USER'] = $authenticationProphecy->reveal();
258 $documentTemplateProphecy = $this->prophesize(DocumentTemplate::class);
259 $GLOBALS[
'TBE_TEMPLATE'] = $documentTemplateProphecy->reveal();
261 $this->loginControllerMock = $this->getAccessibleMock(
262 LoginController::class,
263 [
'isLoginInProgress',
'redirectToUrl'],
270 $this->loginControllerMock->method(
'isLoginInProgress')->willReturn(
true);
271 $this->loginControllerMock->_set(
'loginRefresh',
true);
273 $this->loginControllerMock->_call(
'checkRedirect', $this->prophesize(ServerRequest::class)->reveal());
275 self::assertContains(
'window.opener.TYPO3.LoginRefresh.startTask();', $documentTemplateProphecy->JScode);
283 $GLOBALS[
'BE_USER'] = $this->prophesize(BackendUserAuthentication::class)->reveal();
284 $this->loginControllerMock = $this->getAccessibleMock(
285 LoginController::class,
292 $GLOBALS[
'BE_USER']->user[
'uid'] =
null;
294 $this->loginControllerMock->expects($this->never())->method(
'redirectToUrl');
295 $this->loginControllerMock->_call(
'checkRedirect', $this->prophesize(ServerRequest::class)->reveal());
303 if (!self::$alreadySetUp) {
304 $formProtectionProphecy = $this->prophesize(BackendFormProtection::class);
305 GeneralUtility::addInstance(BackendFormProtection::class, $formProtectionProphecy->reveal());
306 self::$alreadySetUp =
true;