Skip to content

Commit 01beacf

Browse files
committed
Added anti-regression test for #373
(cherry picked from commit c7734db)
1 parent 75bee57 commit 01beacf

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ build/
7070
*.tlb
7171
*.tli
7272
*.tlh
73-
*.tmp
7473
*.tmp_proj
7574
*.log
7675
*.vspscc
7776
*.vssscc
7877
.builds
7978
*.pidb
80-
*.log
8179
*.scc
8280

8381
# Visual C++ cache files
@@ -196,7 +194,6 @@ $RECYCLE.BIN/
196194
*.egg
197195
*.egg-info
198196
dist/
199-
build/
200197
eggs/
201198
parts/
202199
# var/
@@ -233,4 +230,5 @@ nbproject/
233230
#Composer
234231
vendor/
235232
# composer.lock
236-
composer.phar
233+
composer.phar
234+
/cache/

bin/ci/run_tests.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@
44
* @author Georges.L (Geolim4) <[email protected]>
55
*/
66

7+
function glob_recursive($pattern, $flags = 0)
8+
{
9+
$files = glob($pattern, $flags);
10+
11+
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
12+
{
13+
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
14+
}
15+
16+
return $files;
17+
}
18+
719
$status = 0;
820
$driver = (!empty($argv[1]) ? ucfirst($argv[1]) : 'Files');
9-
1021
$testDir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests');
1122

12-
foreach (glob($testDir . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
23+
foreach (glob_recursive($testDir . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
1324
echo "\e[97m--\n";
1425
$command = "php -f {$filename} {$driver}";
1526
echo "\e[33mphpfastcache@test \e[34m~ \e[92m# \e[91m" . $command . "\n";

tests/issues/Github-373.test.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
5+
* @author Georges.L (Geolim4) <[email protected]>
6+
*/
7+
use phpFastCache\CacheManager;
8+
9+
chdir(__DIR__);
10+
require_once __DIR__ . '/../../src/autoload.php';
11+
12+
$status = 0;
13+
echo "Testing Github issue #373 - Files driver issue after clearing cache\n";
14+
15+
CacheManager::setDefaultConfig(array('path' => __DIR__ . '/../../cache'));
16+
$cacheInstance = CacheManager::getInstance('Files');
17+
18+
$key = 'test';
19+
$cacheItem = $cacheInstance->getItem($key);
20+
$cacheItem->set('value');
21+
22+
$cacheInstance->save($cacheItem);
23+
$cacheInstance->deleteItem($key);
24+
$cacheInstance->clear();
25+
26+
try {
27+
$has = $cacheInstance->hasItem($key);
28+
echo "[PASS] No error thrown while trying to test if an item exists after clearing\n";
29+
} catch (Exception $e) {
30+
$status = 255;
31+
echo "[FAIL] An error has been thrown while trying to test if an item exists after clearing\n";
32+
}
33+
34+
exit($status);

0 commit comments

Comments
 (0)