‪TYPO3CMS  10.4
SetupModuleControllerTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪SetupModuleControllerTest extends UnitTestCase
26 {
31  {
32  $setupModuleControllerMock = $this->getAccessibleMock(
33  SetupModuleController::class,
34  ['getFlashMessage', 'enqueueFlashMessages'],
35  [],
36  '',
37  false
38  );
39  $setupModuleControllerMock->_set('setupIsUpdated', true);
40 
41  $setupModuleControllerMock
42  ->expects(self::atMost(2))
43  ->method('getFlashMessage')
44  ->withConsecutive(
45  ['setupWasUpdated', 'UserSettings'],
46  ['activateChanges', '']
47  );
48 
49  $setupModuleControllerMock->_call('addFlashMessages');
50  }
51 
56  {
57  $setupModuleControllerMock = $this->getAccessibleMock(
58  SetupModuleController::class,
59  ['getFlashMessage', 'enqueueFlashMessages'],
60  [],
61  '',
62  false
63  );
64  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
65 
66  $setupModuleControllerMock
67  ->expects(self::atMost(2))
68  ->method('getFlashMessage')
69  ->withConsecutive(
70  ['settingsAreReset', 'resetConfiguration'],
71  ['activateChanges', '']
72  );
73 
74  $setupModuleControllerMock->_call('addFlashMessages');
75  }
76 
81  {
82  $setupModuleControllerMock = $this->getAccessibleMock(
83  SetupModuleController::class,
84  ['getFlashMessage', 'enqueueFlashMessages'],
85  [],
86  '',
87  false
88  );
89  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
90  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_UPDATED);
91 
92  $setupModuleControllerMock
93  ->expects(self::once())
94  ->method('getFlashMessage')
95  ->withConsecutive(
96  ['newPassword_ok', 'newPassword']
97  );
98 
99  $setupModuleControllerMock->_call('addFlashMessages');
100  }
101 
106  {
107  $setupModuleControllerMock = $this->getAccessibleMock(
108  SetupModuleController::class,
109  ['getFlashMessage', 'enqueueFlashMessages'],
110  [],
111  '',
112  false
113  );
114  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
115  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_OLD_WRONG);
116 
117  $setupModuleControllerMock
118  ->expects(self::once())
119  ->method('getFlashMessage')
120  ->withConsecutive(
121  ['oldPassword_failed', 'newPassword']
122  );
123 
124  $setupModuleControllerMock->_call('addFlashMessages');
125  }
126 
131  {
132  $setupModuleControllerMock = $this->getAccessibleMock(
133  SetupModuleController::class,
134  ['getFlashMessage', 'enqueueFlashMessages'],
135  [],
136  '',
137  false
138  );
139  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
140  $setupModuleControllerMock->_set('passwordIsUpdated', ‪SetupModuleController::PASSWORD_NOT_THE_SAME);
141 
142  $setupModuleControllerMock
143  ->expects(self::once())
144  ->method('getFlashMessage')
145  ->withConsecutive(
146  ['newPassword_failed', 'newPassword']
147  );
148 
149  $setupModuleControllerMock->_call('addFlashMessages');
150  }
151 
156  {
157  $setupModuleControllerMock = $this->getAccessibleMock(
158  SetupModuleController::class,
159  ['getFlashMessage', 'enqueueFlashMessages'],
160  [],
161  '',
162  false
163  );
164 
165  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
166  $flashMessage1 = new ‪FlashMessage('foo', 'bar');
167  $flashMessage2 = new ‪FlashMessage('bar', 'foo');
168  $setupModuleControllerMock
169  ->expects(self::atMost(2))
170  ->method('getFlashMessage')
171  ->withConsecutive(
172  ['settingsAreReset', 'resetConfiguration'],
173  ['activateChanges', '']
174  )->willReturnOnConsecutiveCalls(
175  $flashMessage1,
176  $flashMessage2
177  );
178 
179  $setupModuleControllerMock
180  ->expects(self::once())
181  ->method('enqueueFlashMessages')
182  ->with([$flashMessage1, $flashMessage2]);
183  $setupModuleControllerMock->_call('addFlashMessages');
184  }
185 }
‪TYPO3\CMS\Setup\Tests\Unit\Controller
Definition: SetupModuleControllerTest.php:16
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_OLD_WRONG
‪const PASSWORD_OLD_WRONG
Definition: SetupModuleController.php:76
‪TYPO3\CMS\Setup\Controller\SetupModuleController
Definition: SetupModuleController.php:55
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessagesToQueue
‪addFlashMessagesAddsMessagesToQueue()
Definition: SetupModuleControllerTest.php:155
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_UPDATED
‪const PASSWORD_UPDATED
Definition: SetupModuleController.php:65
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest
Definition: SetupModuleControllerTest.php:26
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfSettingsAreResetToDefault
‪addFlashMessagesAddsMessageIfSettingsAreResetToDefault()
Definition: SetupModuleControllerTest.php:55
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfOldPasswordWasWrong
‪addFlashMessagesAddsMessageIfOldPasswordWasWrong()
Definition: SetupModuleControllerTest.php:105
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated
‪addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated()
Definition: SetupModuleControllerTest.php:80
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪TYPO3\CMS\Setup\Controller\SetupModuleController\PASSWORD_NOT_THE_SAME
‪const PASSWORD_NOT_THE_SAME
Definition: SetupModuleController.php:70
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessagesIfSetupIsUpdated
‪addFlashMessagesAddsMessagesIfSetupIsUpdated()
Definition: SetupModuleControllerTest.php:30
‪TYPO3\CMS\Setup\Tests\Unit\Controller\SetupModuleControllerTest\addFlashMessagesAddsMessageIfPasswordsNotTheSame
‪addFlashMessagesAddsMessageIfPasswordsNotTheSame()
Definition: SetupModuleControllerTest.php:130