[Cache] Rely on mock for Doctrine ArrayCache
This commit is contained in:
parent
28f4662935
commit
e4973ad8dc
|
@ -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
|
||||
|
|
|
@ -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