‪TYPO3CMS  ‪main
RedisSessionBackendTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
20 use PHPUnit\Framework\Attributes\Test;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪RedisSessionBackendTest extends UnitTestCase
25 {
26  protected function ‪setUp(): void
27  {
28  if (!class_exists(\Redis::class)) {
29  self::markTestSkipped('Redis class needs to be available to test RedisSessionBackend');
30  }
31  parent::setUp();
32  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
33  }
34 
35  #[Test]
36  public function ‪databaseConfigurationMustBeInteger(): void
37  {
38  $this->expectException(\InvalidArgumentException::class);
39  $this->expectExceptionCode(1481270871);
40  $subject = new ‪RedisSessionBackend();
41  $subject->initialize(
42  'default',
43  [
44  'database' => 'numberZero',
45  ]
46  );
47  $subject->validateConfiguration();
48  }
49 
50  #[Test]
52  {
53  $subject = new ‪RedisSessionBackend();
54  $subject->initialize(
55  'default',
56  [
57  'database' => -1,
58  ]
59  );
60 
61  $this->expectException(\InvalidArgumentException::class);
62  $this->expectExceptionCode(1481270923);
63  $subject->validateConfiguration();
64  }
65 }
‪TYPO3\CMS\Core\Tests\Unit\Session\Backend\RedisSessionBackendTest
Definition: RedisSessionBackendTest.php:25
‪TYPO3\CMS\Core\Tests\Unit\Session\Backend
Definition: DatabaseSessionBackendTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Session\Backend\RedisSessionBackendTest\databaseConfigurationMustBeZeroOrGreater
‪databaseConfigurationMustBeZeroOrGreater()
Definition: RedisSessionBackendTest.php:51
‪TYPO3\CMS\Core\Tests\Unit\Session\Backend\RedisSessionBackendTest\setUp
‪setUp()
Definition: RedisSessionBackendTest.php:26
‪TYPO3\CMS\Core\Session\Backend\RedisSessionBackend
Definition: RedisSessionBackend.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Session\Backend\RedisSessionBackendTest\databaseConfigurationMustBeInteger
‪databaseConfigurationMustBeInteger()
Definition: RedisSessionBackendTest.php:36