40 $GLOBALS[
'BE_USER'] = $this->getMock(
41 'TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication',
42 array(
'getSessionData',
'setAndSaveSessionData')
44 $GLOBALS[
'BE_USER']->user[
'uid'] = 1;
47 'TYPO3\\CMS\\Core\\FormProtection\BackendFormProtection',
48 array(
'acquireLock',
'releaseLock',
'getLanguageService',
'isAjaxRequest')
76 $this->assertInstanceOf(
77 'TYPO3\\CMS\\Core\\Authentication\BackendUserAuthentication',
91 ->expects($this->once())
92 ->method(
'getSessionData')
93 ->with(
'formSessionToken')
94 ->will($this->returnValue(array()));
95 $this->subject->_call(
'retrieveSessionToken');
102 $sessionToken =
'881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd';
105 $formInstanceName =
'42';
108 $formName . $action . $formInstanceName . $sessionToken
112 ->expects($this->atLeastOnce())
113 ->method(
'getSessionData')
114 ->with(
'formSessionToken')
115 ->will($this->returnValue($sessionToken));
117 $this->subject->_call(
'retrieveSessionToken');
120 $this->subject->validateToken($tokenId, $formName, $action, $formInstanceName)
128 public function restoreSessionTokenFromRegistryThrowsExceptionIfSessionTokenIsEmpty() {
130 $registryMock = $this->getMock(
'TYPO3\\CMS\\Core\\Registry');
131 $this->subject->injectRegistry($registryMock);
132 $this->subject->setSessionTokenFromRegistry();
140 $this->subject->_set(
'sessionToken', $sessionToken);
142 ->expects($this->once())
143 ->method(
'setAndSaveSessionData')
144 ->with(
'formSessionToken', $sessionToken);
145 $this->subject->persistSessionToken();
156 public function createValidationErrorMessageAddsFlashMessage() {
158 $flashMessageServiceMock = $this->getMock(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
160 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService',
161 $flashMessageServiceMock
163 $flashMessageQueueMock = $this->getMock(
164 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue',
170 $flashMessageServiceMock
171 ->expects($this->once())
172 ->method(
'getMessageQueueByIdentifier')
173 ->will($this->returnValue($flashMessageQueueMock));
174 $flashMessageQueueMock
175 ->expects($this->once())
177 ->with($this->isInstanceOf(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage'))
178 ->will($this->returnCallback(array($this,
'enqueueFlashMessageCallback')));
180 $languageServiceMock = $this->getMock(
'TYPO3\CMS\Lang\LanguageService', array(), array(),
'', FALSE);
181 $languageServiceMock->expects($this->once())->method(
'sL')->will($this->returnValue(
'foo'));
182 $this->subject->expects($this->once())->method(
'getLanguageService')->will($this->returnValue($languageServiceMock));
184 $this->subject->_call(
'createValidationErrorMessage');
191 $this->assertEquals(\
TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, $flashMessage->getSeverity());
197 public function createValidationErrorMessageAddsErrorFlashMessageButNotInSessionInAjaxRequest() {
199 $flashMessageServiceMock = $this->getMock(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
201 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService',
202 $flashMessageServiceMock
204 $flashMessageQueueMock = $this->getMock(
205 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue',
211 $flashMessageServiceMock
212 ->expects($this->once())
213 ->method(
'getMessageQueueByIdentifier')
214 ->will($this->returnValue($flashMessageQueueMock));
215 $flashMessageQueueMock
216 ->expects($this->once())
218 ->with($this->isInstanceOf(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage'))
219 ->will($this->returnCallback(array($this,
'enqueueAjaxFlashMessageCallback')));
221 $languageServiceMock = $this->getMock(
'TYPO3\CMS\Lang\LanguageService', array(), array(),
'', FALSE);
222 $languageServiceMock->expects($this->once())->method(
'sL')->will($this->returnValue(
'foo'));
223 $this->subject->expects($this->once())->method(
'getLanguageService')->will($this->returnValue($languageServiceMock));
225 $this->subject->expects($this->any())->method(
'isAjaxRequest')->will($this->returnValue(TRUE));
226 $this->subject->_call(
'createValidationErrorMessage');
233 $this->assertFalse($flashMessage->isSessionMessage());
static getSingletonInstances()
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static hmac($input, $additionalSecret='')
static resetSingletonInstances(array $newSingletonInstances)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]