TYPO3 CMS  TYPO3_7-6
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 
24 {
25 
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($this->atMost(2))
43  ->method('getFlashMessage')
44  ->withConsecutive(
45  ['setupWasUpdated', 'UserSettings'],
46  ['activateChanges', '']
47  );
48 
49  $setupModuleControllerMock->_call('addFlashMessages');
50  }
51 
57  {
58  $setupModuleControllerMock = $this->getAccessibleMock(
59  SetupModuleController::class,
60  ['getFlashMessage', 'enqueueFlashMessages'],
61  [],
62  '',
63  false
64  );
65  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
66 
67  $setupModuleControllerMock
68  ->expects($this->atMost(2))
69  ->method('getFlashMessage')
70  ->withConsecutive(
71  ['settingsAreReset', 'resetConfiguration'],
72  ['activateChanges', '']
73  );
74 
75  $setupModuleControllerMock->_call('addFlashMessages');
76  }
77 
83  {
84  $setupModuleControllerMock = $this->getAccessibleMock(
85  SetupModuleController::class,
86  ['getFlashMessage', 'enqueueFlashMessages'],
87  [],
88  '',
89  false
90  );
91  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
92  $setupModuleControllerMock->_set('passwordIsUpdated', SetupModuleController::PASSWORD_UPDATED);
93 
94  $setupModuleControllerMock
95  ->expects($this->once())
96  ->method('getFlashMessage')
97  ->withConsecutive(
98  ['newPassword_ok', 'newPassword']
99  );
100 
101  $setupModuleControllerMock->_call('addFlashMessages');
102  }
103 
109  {
110  $setupModuleControllerMock = $this->getAccessibleMock(
111  SetupModuleController::class,
112  ['getFlashMessage', 'enqueueFlashMessages'],
113  [],
114  '',
115  false
116  );
117  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
118  $setupModuleControllerMock->_set('passwordIsUpdated', SetupModuleController::PASSWORD_OLD_WRONG);
119 
120  $setupModuleControllerMock
121  ->expects($this->once())
122  ->method('getFlashMessage')
123  ->withConsecutive(
124  ['oldPassword_failed', 'newPassword']
125  );
126 
127  $setupModuleControllerMock->_call('addFlashMessages');
128  }
129 
135  {
136  $setupModuleControllerMock = $this->getAccessibleMock(
137  SetupModuleController::class,
138  ['getFlashMessage', 'enqueueFlashMessages'],
139  [],
140  '',
141  false
142  );
143  $setupModuleControllerMock->_set('passwordIsSubmitted', true);
144  $setupModuleControllerMock->_set('passwordIsUpdated', SetupModuleController::PASSWORD_NOT_THE_SAME);
145 
146  $setupModuleControllerMock
147  ->expects($this->once())
148  ->method('getFlashMessage')
149  ->withConsecutive(
150  ['newPassword_failed', 'newPassword']
151  );
152 
153  $setupModuleControllerMock->_call('addFlashMessages');
154  }
155 
161  {
162  $setupModuleControllerMock = $this->getAccessibleMock(
163  SetupModuleController::class,
164  ['getFlashMessage', 'enqueueFlashMessages'],
165  [],
166  '',
167  false
168  );
169 
170  $setupModuleControllerMock->_set('settingsAreResetToDefault', true);
171  $flashMessage1 = new FlashMessage('foo', 'bar');
172  $flashMessage2 = new FlashMessage('bar', 'foo');
173  $setupModuleControllerMock
174  ->expects($this->atMost(2))
175  ->method('getFlashMessage')
176  ->withConsecutive(
177  ['settingsAreReset', 'resetConfiguration'],
178  ['activateChanges', '']
179  )->willReturnOnConsecutiveCalls(
180  $flashMessage1,
181  $flashMessage2
182  );
183 
184  $setupModuleControllerMock
185  ->expects($this->once())
186  ->method('enqueueFlashMessages')
187  ->with([$flashMessage1, $flashMessage2]);
188  $setupModuleControllerMock->_call('addFlashMessages');
189  }
190 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)