File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ * This file is part of Aplus Framework Cache Library.
4+ *
5+ * (c) Natan Felles <natanfelles@gmail.com>
6+ *
7+ * For the full copyright and license information, please view the LICENSE
8+ * file that was distributed with this source code.
9+ */
10+ namespace Tests \Cache ;
11+
12+ use Framework \Cache \ApcuCache ;
13+
14+ final class ApcuCacheTest extends TestCase
15+ {
16+ public function setUp () : void
17+ {
18+ $ loaded = \extension_loaded ('apcu ' );
19+ if (!$ loaded ) {
20+ throw new \RuntimeException ('APCu extension is not loaded ' );
21+ }
22+ \var_dump ('apcu_cache_info(): ' );
23+ \var_dump (\apcu_cache_info ());
24+ if (!\apcu_enabled ()) {
25+ // throw new \RuntimeException('APCu extension is not enabled');
26+ }
27+
28+ $ this ->cache = new ApcuCache (
29+ $ this ->configs ,
30+ $ this ->prefix ,
31+ $ this ->serializer ,
32+ $ this ->getLogger ()
33+ );
34+ }
35+
36+ public function testSerializer () : void
37+ {
38+ $ this ->cache = new ApcuCache (
39+ $ this ->configs ,
40+ $ this ->prefix ,
41+ $ this ->serializer ->value ,
42+ $ this ->getLogger ()
43+ );
44+ $ this ->expectException (\ValueError::class);
45+ $ this ->expectExceptionMessage (
46+ '"foo" is not a valid backing value for enum Framework\Cache\Serializer '
47+ );
48+ $ this ->cache = new ApcuCache (
49+ $ this ->configs ,
50+ $ this ->prefix ,
51+ 'foo ' ,
52+ $ this ->getLogger ()
53+ );
54+ }
55+
56+ public function testDefaultConfigs () : void
57+ {
58+ self ::assertInstanceOf (ApcuCache::class, new ApcuCache ());
59+ }
60+ }
Original file line number Diff line number Diff line change 99 */
1010namespace Tests \Cache ;
1111
12+ use Framework \Cache \ApcuCache ;
1213use Framework \Cache \Cache ;
1314use Framework \Cache \Debug \CacheCollector ;
1415use Framework \Cache \FilesCache ;
@@ -245,6 +246,7 @@ public function getHandler() : string
245246 $ this ->cache ->setDebugCollector ($ collector );
246247 // @phpstan-ignore-next-line
247248 $ handler = match ($ this ->cache ::class) {
249+ ApcuCache::class => 'apcu ' ,
248250 FilesCache::class => 'files ' ,
249251 MemcachedCache::class => 'memcached ' ,
250252 RedisCache::class => 'redis ' ,
You canβt perform that action at this time.
0 commit comments