‪TYPO3CMS  9.5
SetupModuleControllerTest.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 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪SetupModuleControllerTest extends UnitTestCase
25 {
30  {
31  $setupModuleControllerMock = $this->getAccessibleMock(
32  SetupModuleController::class,
33  ['getFlashMessage', 'enqueueFlashMessages'],
34  [],
35  '',
36  false
37  );
38  $setupModuleControllerMock->_set('setupIsUpdated', true);
39 
40  $setupModuleControllerMock
41  ->expects($this->atMost(2))
42  ->method('getFlashMessage')
43  ->withConsecutive(
44  ['setupWasUpdated', 'UserSettings'],
45  ['activateChanges', '']
46  );
47 
48  $setupModuleControllerMock->_call('addFlashMessages');
49  }
50 
55  {
56  $setupModuleControllerMock = $this->getAccessibleMock(
57  SetupModuleController::class,
58  ['getFlashMessage', 'enqueueFlashMessages'],
59  [],
60  '',
61  false
62  );
63  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
64 
65  $setupModuleControllerMock
66  ->expects($this->atMost(2))
67  ->method('getFlashMessage')
68  ->withConsecutive(
69  ['settingsAreReset', 'resetConfiguration'],
70  ['activateChanges', '']
71  );
72 
73  $setupModuleControllerMock->_call('addFlashMessages');
74  }
75 
80  {
81  $setupModuleControllerMock = $this->getAccessibleMock(
82  SetupModuleController::class,
83  ['getFlashMessage', 'enqueueFlashMessages'],
84  [],
85  '',
86  false
87  );
88  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
89  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_UPDATED);
90 
91  $setupModuleControllerMock
92  ->expects($this->once())
93  ->method('getFlashMessage')
94  ->withConsecutive(
95  ['newPassword_ok', 'newPassword']
96  );
97 
98  $setupModuleControllerMock->_call('addFlashMessages');
99  }
100 
105  {
106  $setupModuleControllerMock = $this->getAccessibleMock(
107  SetupModuleController::class,
108  ['getFlashMessage', 'enqueueFlashMessages'],
109  [],
110  '',
111  false
112  );
113  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
114  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_OLD_WRONG);
115 
116  $setupModuleControllerMock
117  ->expects($this->once())
118  ->method('getFlashMessage')
119  ->withConsecutive(
120  ['oldPassword_failed', 'newPassword']
121  );
122 
123  $setupModuleControllerMock->_call('addFlashMessages');
124  }
125 
130  {
131  $setupModuleControllerMock = $this->getAccessibleMock(
132  SetupModuleController::class,
133  ['getFlashMessage', 'enqueueFlashMessages'],
134  [],
135  '',
136  false
137  );
138  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
139  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_NOT_THE_SAME);
140 
141  $setupModuleControllerMock
142  ->expects($this->once())
143  ->method('getFlashMessage')
144  ->withConsecutive(
145  ['newPassword_failed', 'newPassword']
146  );
147 
148  $setupModuleControllerMock->_call('addFlashMessages');
149  }
150 
155  {
156  $setupModuleControllerMock = $this->getAccessibleMock(
157  SetupModuleController::class,
158  ['getFlashMessage', 'enqueueFlashMessages'],
159  [],
160  '',
161  false
162  );
163 
164  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
165  $flashMessage1 = new ‪FlashMessage('foo', 'bar');
166  $flashMessage2 = new ‪FlashMessage('bar', 'foo');
167  $setupModuleControllerMock
168  ->expects($this->atMost(2))
169  ->method('getFlashMessage')
170  ->withConsecutive(
171  ['settingsAreReset', 'resetConfiguration'],
172  ['activateChanges', '']
173  )->willReturnOnConsecutiveCalls(
174  $flashMessage1,
175  $flashMessage2
176  );
177 
178  $setupModuleControllerMock
179  ->expects($this->once())
180  ->method('enqueueFlashMessages')
181  ->with([$flashMessage1, $flashMessage2]);
182  $setupModuleControllerMock->_call('addFlashMessages');
183  }
184 }
‪TYPO3\CMS\Setup\Tests\Unit\Controller
Definition: SetupModuleControllerTest.php:2
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_OLD_WRONG
‪const PASSWORD_OLD_WRONG
Definition: SetupModuleController.php:70
‪TYPO3\CMS\Setup\Controller\SetupModuleController
Definition: SetupModuleController.php:49
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessagesToQueue
‪addFlashMessagesAddsMessagesToQueue()
Definition: SetupModuleControllerTest.php:154
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_UPDATED
‪const PASSWORD_UPDATED
Definition: SetupModuleController.php:59
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest
Definition: SetupModuleControllerTest.php:25
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfSettingsAreResetToDefault
‪addFlashMessagesAddsMessageIfSettingsAreResetToDefault()
Definition: SetupModuleControllerTest.php:54
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfOldPasswordWasWrong
‪addFlashMessagesAddsMessageIfOldPasswordWasWrong()
Definition: SetupModuleControllerTest.php:104
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated
‪addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated()
Definition: SetupModuleControllerTest.php:79
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_NOT_THE_SAME
‪const PASSWORD_NOT_THE_SAME
Definition: SetupModuleController.php:64
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessagesIfSetupIsUpdated
‪addFlashMessagesAddsMessagesIfSetupIsUpdated()
Definition: SetupModuleControllerTest.php:29
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfPasswordsNotTheSame
‪addFlashMessagesAddsMessageIfPasswordsNotTheSame()
Definition: SetupModuleControllerTest.php:129