From abb4671bfc7086f079aa00a3c684d41399987a47 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 10 Apr 2014 03:42:11 +0200 Subject: [PATCH] Removing usage of memcache cache in tests (HHVM gets stuck on them on local setups) --- .../ORM/Functional/Ticket/DDC742Test.php | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php index ad4fad95b..cdef5aa42 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php @@ -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();