Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64d196a

Browse filesBrowse files
committed
[Cache] Added test for ApcuAdapter when using in CLI
1 parent 195d949 commit 64d196a
Copy full SHA for 64d196a

File tree

1 file changed

+27
-1
lines changed
Filter options

1 file changed

+27
-1
lines changed

‎src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Cache\Tests\Adapter;
1313

14+
use Psr\Log\NullLogger;
1415
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1516

1617
class ApcuAdapterTest extends AdapterTestCase
@@ -23,9 +24,14 @@ class ApcuAdapterTest extends AdapterTestCase
2324

2425
public function createCachePool($defaultLifetime = 0)
2526
{
26-
if (!function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === PHP_SAPI && !ini_get('apc.enable_cli'))) {
27+
if (!function_exists('apcu_fetch') || !ini_get('apc.enabled')) {
2728
$this->markTestSkipped('APCu extension is required.');
2829
}
30+
if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
31+
if ('testWithCliSapi' !== $this->getName()) {
32+
$this->markTestSkipped('APCu extension is required.');
33+
}
34+
}
2935
if ('\\' === DIRECTORY_SEPARATOR) {
3036
$this->markTestSkipped('Fails transiently on Windows.');
3137
}
@@ -70,4 +76,24 @@ public function testVersion()
7076
$this->assertFalse($item->isHit());
7177
$this->assertNull($item->get());
7278
}
79+
80+
public function testWithCliSapi()
81+
{
82+
try {
83+
// disable PHPUnit error handler to mimic a production environment
84+
$isCalled = false;
85+
set_error_handler(function () use (&$isCalled) {
86+
$isCalled = true;
87+
});
88+
$pool = new ApcuAdapter(str_replace('\\', '.', __CLASS__));
89+
$pool->setLogger(new NullLogger());
90+
91+
$item = $pool->getItem('foo');
92+
$item->isHit();
93+
$pool->save($item->set('bar'));
94+
$this->assertFalse($isCalled);
95+
} finally {
96+
restore_error_handler();
97+
}
98+
}
7399
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.