Skip to content

Commit 44f1a63

Browse files
committed
Enable OPCache in the optional interface test
1 parent fd190aa commit 44f1a63

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

ext/opcache/tests/optional_interfaces.phpt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,38 @@ server
1212

1313
$interfaceFile = __DIR__.'/optional_interfaces_interface.inc';
1414

15-
file_put_contents(__DIR__.'/optional_interfaces_script.php', <<<SCRIPT
15+
file_put_contents(__DIR__.'/optional_interfaces_script.php', <<<'SCRIPT'
1616
<?php
1717
18-
@(include __DIR__.'/optional_interfaces_interface.inc');
18+
$classFile = __DIR__.'/optional_interfaces_class.inc';
19+
$interfaceFile = __DIR__.'/optional_interfaces_interface.inc';
20+
21+
if (opcache_is_script_cached($classFile))
22+
echo "Class is cached\n";
23+
else
24+
echo "Class is not cached\n";
25+
26+
@(include $interfaceFile);
1927
2028
if (interface_exists('OpcachedInterface'))
2129
echo "OpcachedInterface is defined\n";
2230
else
2331
echo "OpcachedInterface is not defined\n";
2432
25-
include __DIR__.'/optional_interfaces_class.inc';
33+
$hitsBefore = opcache_get_status()['opcache_statistics']['hits'];
34+
35+
include $classFile;
36+
37+
if (opcache_get_status()['opcache_statistics']['hits'] > $hitsBefore)
38+
echo "Class loaded from OPCache\n";
39+
else
40+
echo "Class loaded from file\n";
2641
2742
echo "OpcachedClass implements:".implode(', ', class_implements('OpcachedClass'))."\n\n";
2843
SCRIPT);
2944

3045
include __DIR__.'/php_cli_server.inc';
31-
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1');
46+
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d zend_extension=opcache');
3247

3348
$uri = 'http://' . PHP_CLI_SERVER_ADDRESS . '/optional_interfaces_script.php';
3449

@@ -46,11 +61,17 @@ unlink(__DIR__.'/optional_interfaces_script.php');
4661

4762
?>
4863
--EXPECT--
64+
Class is not cached
4965
OpcachedInterface is not defined
66+
Class loaded from file
5067
OpcachedClass implements:
5168

69+
Class is cached
5270
OpcachedInterface is defined
71+
Class loaded from OPCache
5372
OpcachedClass implements:OpcachedInterface
5473

74+
Class is cached
5575
OpcachedInterface is not defined
76+
Class loaded from OPCache
5677
OpcachedClass implements:

0 commit comments

Comments
 (0)