Skip to content

Commit e36a92d

Browse files
committed
Simplify test
1 parent fbb4194 commit e36a92d

File tree

3 files changed

+28
-41
lines changed

3 files changed

+28
-41
lines changed

ext/opcache/tests/cleanup_helper.inc

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
function test() {}

ext/opcache/tests/gh16979_check_file_cache_function.phpt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22
GH-16979: Test opcache_is_script_cached_in_file_cache function
33
--SKIPIF--
44
<?php
5-
// Ensure the cache directory exists BEFORE OPcache needs it
6-
$cacheDir = __DIR__ . '/gh16979_cache';
7-
if (!is_dir($cacheDir)) {
8-
@mkdir($cacheDir, 0777, true);
9-
}
10-
// Check if mkdir failed potentially due to permissions
11-
if (!is_dir($cacheDir) || !is_writable($cacheDir)) {
12-
die('skip Could not create or write to cache directory: ' . $cacheDir);
13-
}
5+
@mkdir(__DIR__ . '/gh16979_cache', 0777, true);
146
?>
157
--INI--
168
opcache.enable=1
@@ -23,23 +15,34 @@ opcache
2315
--FILE--
2416
<?php
2517

26-
opcache_compile_file(__FILE__);
27-
28-
var_dump(opcache_is_script_cached_in_file_cache(__FILE__));
29-
30-
opcache_invalidate(__FILE__, true); // force=true
31-
32-
var_dump(opcache_is_script_cached_in_file_cache(__FILE__));
18+
$file = __DIR__ . '/gh16979_check_file_cache_function.inc';
19+
var_dump(opcache_is_script_cached_in_file_cache($file));
20+
opcache_compile_file($file);
21+
var_dump(opcache_is_script_cached_in_file_cache($file));
22+
opcache_invalidate($file, force: true);
23+
var_dump(opcache_is_script_cached_in_file_cache($file));
3324

3425
?>
3526
--CLEAN--
3627
<?php
37-
require __DIR__ . '/cleanup_helper.inc';
38-
39-
$cacheDir = __DIR__ . '/gh16979_cache';
40-
41-
removeDirRecursive($cacheDir);
28+
function removeDirRecursive($dir) {
29+
if (!is_dir($dir)) return;
30+
$iterator = new RecursiveIteratorIterator(
31+
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
32+
RecursiveIteratorIterator::CHILD_FIRST
33+
);
34+
foreach ($iterator as $fileinfo) {
35+
if ($fileinfo->isDir()) {
36+
@rmdir($fileinfo->getRealPath());
37+
} else {
38+
@unlink($fileinfo->getRealPath());
39+
}
40+
}
41+
@rmdir($dir);
42+
}
43+
removeDirRecursive(__DIR__ . '/gh16979_cache');
4244
?>
43-
--EXPECTF--
45+
--EXPECT--
46+
bool(false)
4447
bool(true)
4548
bool(false)

0 commit comments

Comments
 (0)