forked from TruCopilot/phpfastcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractProxy.test.php
More file actions
51 lines (41 loc) · 1.63 KB
/
Copy pathAbstractProxy.test.php
File metadata and controls
51 lines (41 loc) · 1.63 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
<?php
/**
* @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> https://www.phpfastcache.com
* @author Georges.L (Geolim4) <contact@geolim4.com>
*/
use Phpfastcache\Core\Item\ExtendedCacheItemInterface;
use Phpfastcache\Helper\TestHelper;
use Phpfastcache\Proxy\PhpfastcacheAbstractProxy;
chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
$testHelper = new TestHelper('phpfastcacheAbstractProxy class');
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
/**
* Dynamic driver-based example
* Class myCustomCacheClass
* @package MyCustom\Project
*/
class CustomMemcachedCacheClass extends PhpfastcacheAbstractProxy
{
public function __construct($driver = '', $config = null)
{
global $defaultDriver;
$driver = $defaultDriver;
parent::__construct($driver, $config);
/**
* That's all !! Your cache class is ready to use
*/
}
}
/**
* Testing memcached as it is declared in .travis.yml
*/
$driverInstance = new CustomMemcachedCacheClass();
if (!is_object($driverInstance->getItem('test'))) {
$testHelper->printFailText('$driverInstance->getItem() returned an invalid var type:' . gettype($driverInstance));
}else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){
$testHelper->printFailText('$driverInstance->getItem() returned an invalid class that does not implements ExtendedCacheItemInterface: ' . get_class($driverInstance));
}else{
$testHelper->printPassText('$driverInstance->getItem() returned a valid class that implements ExtendedCacheItemInterface: ' . get_class($driverInstance));
}
$testHelper->terminateTest();