1
0
mirror of synced 2025-01-19 15:01:40 +03:00

Removing usage of memcache cache in tests (HHVM gets stuck on them on local setups)

This commit is contained in:
Marco Pivetta 2014-04-10 03:42:11 +02:00 committed by fabios
parent e263426cdf
commit abb4671bfc

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Cache\FilesystemCache;
use Doctrine\Common\Collections\ArrayCollection;
/**
@ -9,27 +10,32 @@ use Doctrine\Common\Collections\ArrayCollection;
*/
class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
private $userCm;
private $commentCm;
/**
* @var string
*/
private $testDir;
/**
* @var FilesystemCache
*/
private $cache;
/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();
if (\extension_loaded('memcache') && @fsockopen('localhost', 11211)) {
$memcache = new \Memcache();
$memcache->addServer('localhost');
$memcache->flush();
$testDir = sys_get_temp_dir() . '/DDC742Test' . uniqid();
$cacheDriver = new \Doctrine\Common\Cache\MemcacheCache();
$cacheDriver->setMemcache($memcache);
mkdir($testDir);
$this->_em->getMetadataFactory()->setCacheDriver($cacheDriver);
} else if (\extension_loaded('apc')) {
$this->_em->getMetadataFactory()->setCacheDriver(new \Doctrine\Common\Cache\ApcCache());
} else {
$this->markTestSkipped('Test only works with a cache enabled.');
}
$this->testDir = $testDir;
$this->cache = new FilesystemCache($testDir);
// using a Filesystemcache to ensure that the cached data is serialized
$this->_em->getMetadataFactory()->setCacheDriver($this->cache);
try {
$this->_schemaTool->createSchema(array(
@ -37,7 +43,6 @@ class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC742Comment')
));
} catch(\Exception $e) {
}
// make sure classes will be deserialized from caches
@ -45,6 +50,15 @@ class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getMetadataFactory()->setMetadataFor(__NAMESPACE__ . '\DDC742Comment', null);
}
/**
* {@inheritDoc}
*/
protected function tearDown()
{
$this->cache->deleteAll();
rmdir($this->testDir);
}
public function testIssue()
{
$user = new DDC742User();