|
9 | 9 | use Phpfastcache\Drivers\Fakefiles\Config; |
10 | 10 | use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; |
11 | 11 | use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; |
12 | | -use Phpfastcache\Exceptions\PhpfastcacheLogicException; |
13 | | -use Phpfastcache\Helper\CacheConditionalHelper as CacheConditional; |
14 | 12 | use Phpfastcache\Helper\TestHelper; |
15 | 13 |
|
16 | 14 | chdir(__DIR__); |
|
29 | 27 | } |
30 | 28 |
|
31 | 29 | try { |
32 | | - CacheManager::addCoreDriverOverride('Fakefiles', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
33 | | - $testHelper->printFailText('No exception thrown while trying to override an non-existing driver'); |
34 | | -} catch (PhpfastcacheLogicException $e) { |
35 | | - $testHelper->printPassText('An exception has been thrown while trying to override an non-existing driver'); |
| 30 | + CacheManager::addCustomDriver('Fakefiles', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
| 31 | + $testHelper->printPassText('No exception thrown while trying to add a custom driver'); |
| 32 | +} catch (\Throwable $e) { |
| 33 | + $testHelper->printFailText('An exception has been thrown while trying to add a custom driver'); |
36 | 34 | } |
37 | 35 |
|
38 | 36 | try { |
39 | | - CacheManager::addCoreDriverOverride('', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
| 37 | + CacheManager::addCustomDriver('Fakefiles', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
| 38 | + $testHelper->printFailText('No exception thrown while trying to re-add a the same custom driver'); |
| 39 | +} catch (\Throwable $e) { |
| 40 | + $testHelper->printPassText('An exception has been thrown while trying to re-add a the same custom driver'); |
| 41 | +} |
| 42 | + |
| 43 | +try { |
| 44 | + CacheManager::addCustomDriver('', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
40 | 45 | $testHelper->printFailText('No exception thrown while trying to override an empty driver'); |
41 | 46 | } catch (PhpfastcacheInvalidArgumentException $e) { |
42 | 47 | $testHelper->printPassText('An exception has been thrown while trying to override an empty driver'); |
43 | 48 | } |
44 | 49 |
|
45 | | -CacheManager::addCoreDriverOverride('Files', \Phpfastcache\Drivers\Fakefiles\Driver::class); |
46 | | - |
47 | 50 | try{ |
48 | | - $cacheInstance = CacheManager::getInstance('Files', new Config(['customOption' => true])); |
| 51 | + $cacheInstance = CacheManager::getInstance('Fakefiles', new Config(['customOption' => true])); |
49 | 52 | $testHelper->printPassText('The custom driver is unavailable at the moment and no exception has been thrown.'); |
50 | 53 | }catch (PhpfastcacheDriverCheckException $e){ |
51 | 54 | $testHelper->printPassText('The custom driver is unavailable at the moment and the exception has been catch.'); |
52 | 55 | } |
53 | 56 |
|
54 | | -CacheManager::removeCoreDriverOverride('Files'); |
| 57 | +CacheManager::removeCustomDriver('Fakefiles'); |
55 | 58 |
|
56 | 59 | try{ |
57 | | - $cacheInstance = CacheManager::getInstance('Files'); |
58 | | - $testHelper->printPassText('The custom driver has been removed but is still.'); |
| 60 | + $cacheInstance = CacheManager::getInstance('Fakefiles'); |
| 61 | + $testHelper->printPassText('The custom driver has been removed but is still active.'); |
59 | 62 | }catch (PhpfastcacheDriverCheckException $e){ |
60 | 63 | $testHelper->printPassText('The custom driver is unavailable at the moment and the exception has been catch.'); |
61 | 64 | } |
|
0 commit comments