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