/***************************************************************
* Copyright notice
*
-* (c) 2010 Oliver Klee (typo3-coding@oliverklee.de)
+* (c) 2010-2011 Oliver Klee (typo3-coding@oliverklee.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
return $className;
}
+ /**
+ * Mock session methods in t3lib_beUserAuth
+ *
+ * @return t3lib_beUserAuth Instance of BE_USER object with mocked session storage methods
+ */
+ private function createBackendUserSessionStorageStub() {
+ $className = 't3lib_beUserAuthMocked';
+ if (!class_exists($className)) {
+ eval(
+ 'class ' . $className . ' extends t3lib_beUserAuth {' .
+ ' protected $session=array();' .
+ ' public function getSessionData($key) {' .
+ ' return $this->session[$key];' .
+ ' }' .
+ ' public function setAndSaveSessionData($key,$data) {' .
+ ' $this->session[$key] = $data;' .
+ ' }' .
+ '}'
+ );
+ }
+
+ return $this->getMock($className, array('foo'));// $className;
+ }
////////////////////////////////////
// Tests for the utility functions
);
}
+ /**
+ * @test
+ */
+ public function createBackendUserSessionStorageStubWorkProperly() {
+ $GLOBALS['BE_USER'] = $this->createBackendUserSessionStorageStub();
+
+ $allTokens = array(
+ '12345678' => array(
+ 'formName' => 'foo',
+ 'action' => 'edit',
+ 'formInstanceName' => '42'
+ ),
+ );
+
+ $GLOBALS['BE_USER']->setAndSaveSessionData('tokens', $allTokens);
+
+ $this->assertEquals($GLOBALS['BE_USER']->getSessionData('tokens'), $allTokens);
+ }
+
//////////////////////////////////////////////////////////
// Tests concerning the reading and saving of the tokens
* @test
*/
public function createValidationErrorMessageAddsErrorFlashMessage() {
+ $GLOBALS['BE_USER'] = $this->createBackendUserSessionStorageStub();
$this->fixture->createValidationErrorMessage();
$messages = t3lib_FlashMessageQueue::getAllMessagesAndFlush();