forked from TruCopilot/phpfastcache
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUnsupportedKeyCharacters.test.php
More file actions
54 lines (46 loc) · 2.03 KB
/
UnsupportedKeyCharacters.test.php
File metadata and controls
54 lines (46 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
*
* This file is part of Phpfastcache.
*
* @license MIT License (MIT)
*
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files.
*
* @author Georges.L (Geolim4) <contact@geolim4.com>
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
*/
use Phpfastcache\CacheManager;
use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException;
use Phpfastcache\Tests\Helper\TestHelper;
use Psr\Cache\CacheItemPoolInterface;
chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
$testHelper = new TestHelper('Unsupported key characters');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
$driverInstance = CacheManager::getInstance($defaultDriver);
try {
$driverInstance->getItem('test{test');
$testHelper->assertFail('1/4 An unsupported key character did not get caught by regular expression');
} catch (PhpfastcacheInvalidArgumentException $e) {
$testHelper->assertPass('1/4 An unsupported key character has been caught by regular expression');
}
try {
$driverInstance->getItem(':testtest');
$testHelper->assertFail('2/4 An unsupported key character did not get caught by regular expression');
} catch (PhpfastcacheInvalidArgumentException $e) {
$testHelper->assertPass('2/4 An unsupported key character has been caught by regular expression');
}
try {
$driverInstance->getItem('testtest}');
$testHelper->assertFail('3/4 An unsupported key character did not get caught by regular expression');
} catch (PhpfastcacheInvalidArgumentException $e) {
$testHelper->assertPass('3/4 An unsupported key character has been caught by regular expression');
}
try {
$driverInstance->getItem('testtest');
$testHelper->assertPass('4/4 No exception caught while trying with a key without unsupported character');
} catch (PhpfastcacheInvalidArgumentException $e) {
$testHelper->assertFail('4/4 An exception has been caught while trying with a key without unsupported character');
}
$testHelper->terminateTest();