minor #26605 [Cache] Rely on mock for Doctrine ArrayCache (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[Cache] Rely on mock for Doctrine ArrayCache
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
See also https://github.com/doctrine/cache/pull/253
Commits
-------
e4973ad
[Cache] Rely on mock for Doctrine ArrayCache
This commit is contained in:
commit
2251ec3147
@ -65,6 +65,7 @@
|
||||
<element><string>Cache\IntegrationTests</string></element>
|
||||
<element><string>Doctrine\Common\Cache</string></element>
|
||||
<element><string>Symfony\Component\Cache</string></element>
|
||||
<element><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
|
||||
<element><string>Symfony\Component\Cache\Traits</string></element>
|
||||
<element><string>Symfony\Component\Console</string></element>
|
||||
<element><string>Symfony\Component\HttpFoundation</string></element>
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
|
52
src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php
Normal file
52
src/Symfony/Component/Cache/Tests/Fixtures/ArrayCache.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Fixtures;
|
||||
|
||||
use Doctrine\Common\Cache\CacheProvider;
|
||||
|
||||
class ArrayCache extends CacheProvider
|
||||
{
|
||||
private $data = array();
|
||||
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->doContains($id) ? $this->data[$id][0] : false;
|
||||
}
|
||||
|
||||
protected function doContains($id)
|
||||
{
|
||||
if (!isset($this->data[$id])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expiry = $this->data[$id][1];
|
||||
|
||||
return !$expiry || time() <= $expiry || !$this->doDelete($id);
|
||||
}
|
||||
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$this->data[$id] = array($data, $lifeTime ? time() + $lifeTime : false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function doDelete($id)
|
||||
{
|
||||
unset($this->data[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->data = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Cache\Tests\Simple;
|
||||
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Symfony\Component\Cache\Simple\DoctrineCache;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
|
@ -39,6 +39,7 @@
|
||||
<element><string>Cache\IntegrationTests</string></element>
|
||||
<element><string>Doctrine\Common\Cache</string></element>
|
||||
<element><string>Symfony\Component\Cache</string></element>
|
||||
<element><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
|
||||
<element><string>Symfony\Component\Cache\Traits</string></element>
|
||||
</array>
|
||||
</element>
|
||||
|
Reference in New Issue
Block a user