TYPO3 CMS  TYPO3_8-7
SessionManagerTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
24 
28 class SessionManagerTest extends UnitTestCase
29 {
34  {
35  $subject = new SessionManager();
36  $this->assertInstanceOf(DatabaseSessionBackend::class, $subject->getSessionBackend('BE'));
37  }
38 
43  {
44  $backendProphecy = $this->prophesize(SessionBackendInterface::class);
45  $backendRevelation = $backendProphecy->reveal();
46  $backendClassName = get_class($backendRevelation);
47  $GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['myidentifier'] = [
48  'backend' => $backendClassName,
49  'options' => []
50  ];
51  $backendProphecy->initialize(Argument::cetera())->shouldBeCalled();
52  $backendProphecy->validateConfiguration(Argument::cetera())->shouldBeCalled();
53  GeneralUtility::addInstance($backendClassName, $backendRevelation);
54  $subject = new SessionManager();
55  $this->assertInstanceOf($backendClassName, $subject->getSessionBackend('myidentifier'));
56  }
57 
62  {
63  $this->expectException(\InvalidArgumentException::class);
64  $this->expectExceptionCode(1482234750);
65  $GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['myNewIdentifier'] = 'I am not an array';
66  $subject = new SessionManager();
67  $subject->getSessionBackend('myNewidentifier');
68  }
69 
74  {
75  $this->expectException(\InvalidArgumentException::class);
76  $this->expectExceptionCode(1482235035);
77  $GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['myidentifier'] = [
78  'backend' => \stdClass::class,
79  'options' => []
80  ];
81  (new SessionManager())->getSessionBackend('myidentifier');
82  }
83 }
static addInstance($className, $instance)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']