Skip to content

Commit 75bee57

Browse files
committed
Rewrited tests
1 parent 97df102 commit 75bee57

9 files changed

+48
-14
lines changed

.travis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,4 @@ install:
4242
- ./bin/ci/install_dependencies.sh
4343

4444
script:
45-
- php -f tests/SyntaxChecker.test.php
46-
- php -f tests/Autoload.test.php
47-
- php -f tests/NewCacheInstance.test.php
48-
- php -f tests/Psr6InterfaceImplements.test.php
49-
- php -f tests/AbstractProxy.test.php
50-
- php -f tests/AttachingDetachingMethods.test.php
51-
- php -f tests/ActOnAll.test.php
52-
- php -f tests/EventManager.test.php
45+
- php -f bin/ci/run_tests.php

bin/ci/run_tests.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
4+
* @author Georges.L (Geolim4) <[email protected]>
5+
*/
6+
7+
$status = 0;
8+
$driver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
9+
10+
$testDir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests');
11+
12+
foreach (glob($testDir . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
13+
echo "\e[97m--\n";
14+
$command = "php -f {$filename} {$driver}";
15+
echo "\e[33mphpfastcache@test \e[34m~ \e[92m# \e[91m" . $command . "\n";
16+
exec ($command, $output, $return_var);
17+
echo "=====================================\n";
18+
echo "\e[95m" . implode("\n", $output) . "\n";
19+
echo "=====================================\n";
20+
if($return_var === 0){
21+
echo "\e[32mProcess finished with exit code $return_var";
22+
}else{
23+
echo "\e[31mProcess finished with exit code $return_var";
24+
$status = 255;
25+
}
26+
echo "\n\n\n\n";
27+
/**
28+
* Reset $output to prevent override effects
29+
*/
30+
unset($output);
31+
}
32+
33+
exit($status);

tests/AbstractProxy.test.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
chdir(__DIR__);
1414
require_once __DIR__ . '/../vendor/autoload.php';
1515

16+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1617
$status = 0;
1718
echo "Testing phpFastCacheAbstractProxy class\n";
1819

@@ -25,7 +26,8 @@ class CustomMemcachedCacheClass extends phpFastCacheAbstractProxy
2526
{
2627
public function __construct($driver = '', array $config = [])
2728
{
28-
$driver = 'Memcached';
29+
global $defaultDriver;
30+
$driver = $defaultDriver;
2931
parent::__construct($driver, $config);
3032
/**
3133
* That's all !! Your cache class is ready to use

tests/ActOnAll.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
chdir(__DIR__);
1313
require_once __DIR__ . '/../vendor/autoload.php';
1414

15+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1516
$status = 0;
1617
echo "Testing ActOnAll helper\n";
1718

1819
/**
1920
* Testing memcached as it is declared in .travis.yml
2021
*/
21-
$RedisInstance = CacheManager::getInstance('Redis');
2222
$filesInstance = CacheManager::getInstance('Files');
23+
$RedisInstance = CacheManager::getInstance('Redis');
2324
$MemcacheInstance = CacheManager::getInstance('Memcached');
2425

2526
$actOnAll = new ActOnAll();

tests/AttachingDetachingMethods.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
chdir(__DIR__);
1414
require_once __DIR__ . '/../vendor/autoload.php';
1515

16+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1617
$status = 0;
1718
echo "Testing [a|de]ttaching methods\n";
1819

1920
/**
2021
* Testing memcached as it is declared in .travis.yml
2122
*/
22-
$driverInstance = CacheManager::getInstance('Files');
23+
$driverInstance = CacheManager::getInstance($defaultDriver);
2324

2425
if (!is_object($driverInstance)) {
2526
echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n";

tests/EventManager.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
chdir(__DIR__);
1414
require_once __DIR__ . '/../vendor/autoload.php';
1515

16+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1617
$status = 0;
1718
echo "Testing EventManager\n";
1819

@@ -22,7 +23,7 @@
2223
}
2324
});
2425

25-
$cacheInstance = CacheManager::getInstance('Files');
26+
$cacheInstance = CacheManager::getInstance($defaultDriver);
2627
$cacheKey = 'testItem';
2728

2829
$item = $cacheInstance->getItem($cacheKey);

tests/NewCacheInstance.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
chdir(__DIR__);
1212
require_once __DIR__ . '/../vendor/autoload.php';
1313

14+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1415
$status = 0;
1516
echo "Testing new cache instance\n";
1617

1718
/**
1819
* Testing memcached as it is declared in .travis.yml
1920
*/
20-
$driverInstance = CacheManager::getInstance('Memcached');
21+
$driverInstance = CacheManager::getInstance($defaultDriver);
2122

2223
if (!is_object($driverInstance) || !($driverInstance instanceof ExtendedCacheItemPoolInterface)) {
2324
echo '[FAIL] CacheManager::getInstance() returned wrong data:' . gettype($driverInstance) . "\n";

tests/Psr6InterfaceImplements.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
chdir(__DIR__);
1313
require_once __DIR__ . '/../vendor/autoload.php';
1414

15+
$defaultDriver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
1516
$status = 0;
1617
echo "Testing new cache instance\n";
1718

1819
/**
1920
* Testing memcached as it is declared in .travis.yml
2021
*/
21-
$driverInstance = CacheManager::getInstance('Memcached');
22+
$driverInstance = CacheManager::getInstance($defaultDriver);
2223

2324
if (!is_object($driverInstance)) {
2425
echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n";

tests/SyntaxChecker.test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
55
* @author Georges.L (Geolim4) <[email protected]>
66
*/
7+
78
function read_dir($dir, $ext = null)
89
{
910
$list = [];

0 commit comments

Comments
 (0)