Author: bicou
Date: 2010-03-27 17:01:49 +0100 (Sat, 27 Mar 2010)
New Revision: 28828
Added:
plugins/sfRedisPlugin/trunk/test/
plugins/sfRedisPlugin/trunk/test/bin/
plugins/sfRedisPlugin/trunk/test/bin/prove.php
plugins/sfRedisPlugin/trunk/test/bootstrap/
plugins/sfRedisPlugin/trunk/test/bootstrap/unit.php
plugins/sfRedisPlugin/trunk/test/fixtures/
plugins/sfRedisPlugin/trunk/test/fixtures/project/
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/ProjectConfiguration.class.php
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/redis.yml
plugins/sfRedisPlugin/trunk/test/unit/
plugins/sfRedisPlugin/trunk/test/unit/sfRedisCacheTest.php
Modified:
plugins/sfRedisPlugin/trunk/README
plugins/sfRedisPlugin/trunk/lib/cache/sfRedisCache.class.php
Log:
[sfRedisPlugin] add sfRedisCache tests (use symfony sfCacheDriverTests)
Modified: plugins/sfRedisPlugin/trunk/README
===================================================================
--- plugins/sfRedisPlugin/trunk/README 2010-03-27 15:50:38 UTC (rev 28827)
+++ plugins/sfRedisPlugin/trunk/README 2010-03-27 16:01:49 UTC (rev 28828)
@@ -102,7 +102,6 @@
----
* work with nginx HTTP redis module
-* write tests
LINKS
-----
Modified: plugins/sfRedisPlugin/trunk/lib/cache/sfRedisCache.class.php
===================================================================
--- plugins/sfRedisPlugin/trunk/lib/cache/sfRedisCache.class.php
2010-03-27 15:50:38 UTC (rev 28827)
+++ plugins/sfRedisPlugin/trunk/lib/cache/sfRedisCache.class.php
2010-03-27 16:01:49 UTC (rev 28828)
@@ -67,20 +67,24 @@
if ($lifetime < 1)
{
- $response = $this->remove($key);
+ $ret = $this->remove($key);
}
else
{
$pkey = $this->getKey($key);
$mkey = $this->getKey($key, '_lastmodified');
$pipe = $this->redis->pipeline();
- $pipe->mset(array($pkey => $data, $mkey => $_SERVER['REQUEST_TIME']));
+
+ $pipe->mset(array($pkey => $data, $mkey => time()));
$pipe->expire($pkey, $lifetime);
$pipe->expire($mkey, $lifetime);
- $response = $pipe->execute();
+
+ $reply = $pipe->execute();
+
+ $ret = $reply[0] and $reply[1] and $reply[2];
}
- return $response;
+ return $ret;
}
/**
@@ -116,7 +120,7 @@
{
if (sfCache::ALL === $mode)
{
- $this->removePattern('**');
+ $this->removePattern('*');
}
}
@@ -125,7 +129,8 @@
*/
public function getTimeout($key)
{
- return $_SERVER['REQUEST_TIME'] + $this->redis->ttl($this->getKey($key));
+ $ttl = $this->redis->ttl($this->getKey($key));
+ return $ttl > -1 ? time() + $ttl : 0;
}
/**
@@ -159,7 +164,7 @@
*/
public function isExpired($key)
{
- return $_SERVER['REQUEST_TIME'] >= $this->getTimeout($key);
+ return !$this->getTimeout($key);
}
/**
Added: plugins/sfRedisPlugin/trunk/test/bin/prove.php
===================================================================
--- plugins/sfRedisPlugin/trunk/test/bin/prove.php
(rev 0)
+++ plugins/sfRedisPlugin/trunk/test/bin/prove.php 2010-03-27 16:01:49 UTC
(rev 28828)
@@ -0,0 +1,8 @@
+<?php
+
+include dirname(__FILE__).'/../bootstrap/unit.php';
+
+$h = new lime_harness(new lime_output_color());
+$h->register(sfFinder::type('file')->name('*Test.php')->in(dirname(__FILE__).'/..'));
+
+exit($h->run() ? 0 : 1);
Property changes on: plugins/sfRedisPlugin/trunk/test/bin/prove.php
___________________________________________________________________
Added: svn:mime-type
+ text/x-php
Added: svn:keywords
+ Author Date Id Rev URL
Added: svn:eol-style
+ native
Added: plugins/sfRedisPlugin/trunk/test/bootstrap/unit.php
===================================================================
--- plugins/sfRedisPlugin/trunk/test/bootstrap/unit.php
(rev 0)
+++ plugins/sfRedisPlugin/trunk/test/bootstrap/unit.php 2010-03-27 16:01:49 UTC
(rev 28828)
@@ -0,0 +1,31 @@
+<?php
+
+if (!isset($_SERVER['SYMFONY']))
+{
+ throw new RuntimeException('Could not find symfony core libraries.');
+}
+
+require_once $_SERVER['SYMFONY'].'/autoload/sfCoreAutoload.class.php';
+sfCoreAutoload::register();
+
+$configuration = new
sfProjectConfiguration(dirname(__FILE__).'/../fixtures/project');
+require_once $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
+
+function sfRedisPlugin_autoload_again($class)
+{
+ $autoload = sfSimpleAutoload::getInstance();
+ $autoload->reload();
+ return $autoload->autoload($class);
+}
+spl_autoload_register('sfRedisPlugin_autoload_again');
+
+if (file_exists($config =
dirname(__FILE__).'/../../config/sfRedisPluginConfiguration.class.php'))
+{
+ require_once $config;
+ $plugin_configuration = new sfRedisPluginConfiguration($configuration,
dirname(__FILE__).'/../..', 'sfRedisPlugin');
+}
+else
+{
+ $plugin_configuration = new sfPluginConfigurationGeneric($configuration,
dirname(__FILE__).'/../..', 'sfRedisPlugin');
+}
+
Property changes on: plugins/sfRedisPlugin/trunk/test/bootstrap/unit.php
___________________________________________________________________
Added: svn:mime-type
+ text/x-php
Added: svn:keywords
+ Author Date Id Rev URL
Added: svn:eol-style
+ native
Added:
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/ProjectConfiguration.class.php
===================================================================
---
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/ProjectConfiguration.class.php
(rev 0)
+++
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/ProjectConfiguration.class.php
2010-03-27 16:01:49 UTC (rev 28828)
@@ -0,0 +1,18 @@
+<?php
+
+if (!isset($_SERVER['SYMFONY']))
+{
+ throw new RuntimeException('Could not find symfony core libraries.');
+}
+
+require_once $_SERVER['SYMFONY'].'/autoload/sfCoreAutoload.class.php';
+sfCoreAutoload::register();
+
+class ProjectConfiguration extends sfProjectConfiguration
+{
+ public function setup()
+ {
+ $this->setPlugins(array('sfRedisPlugin'));
+ $this->setPluginPath('sfRedisPlugin', dirname(__FILE__).'/../../../..');
+ }
+}
Property changes on:
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/ProjectConfiguration.class.php
___________________________________________________________________
Added: svn:mime-type
+ text/x-php
Added: svn:keywords
+ Author Date Id Rev URL
Added: svn:eol-style
+ native
Added: plugins/sfRedisPlugin/trunk/test/fixtures/project/config/redis.yml
===================================================================
--- plugins/sfRedisPlugin/trunk/test/fixtures/project/config/redis.yml
(rev 0)
+++ plugins/sfRedisPlugin/trunk/test/fixtures/project/config/redis.yml
2010-03-27 16:01:49 UTC (rev 28828)
@@ -0,0 +1,4 @@
+all:
+ connections:
+ default:
+ host: 192.168.0.10
Property changes on:
plugins/sfRedisPlugin/trunk/test/fixtures/project/config/redis.yml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Author Date Id Rev URL
Added: svn:eol-style
+ native
Added: plugins/sfRedisPlugin/trunk/test/unit/sfRedisCacheTest.php
===================================================================
--- plugins/sfRedisPlugin/trunk/test/unit/sfRedisCacheTest.php
(rev 0)
+++ plugins/sfRedisPlugin/trunk/test/unit/sfRedisCacheTest.php 2010-03-27
16:01:49 UTC (rev 28828)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * sfRedis tests.
+ */
+include dirname(__FILE__).'/../bootstrap/unit.php';
+require_once
$_SERVER['SYMFONY'].'/../test/unit/cache/sfCacheDriverTests.class.php';
+
+$t = new lime_test(64, new lime_output_color());
+
+try
+{
+ new sfRedisCache;
+}
+catch (sfInitializationException $e)
+{
+ $t->skip($e->getMessage(), $plan);
+ return;
+}
+
+// setup
+sfConfig::set('sf_logging_enabled', false);
+
+// ->initialize()
+$t->diag('->initialize()');
+$cache = new sfRedisCache;
+$cache->initialize();
+
+sfCacheDriverTests::launch($t, $cache);
+
Property changes on: plugins/sfRedisPlugin/trunk/test/unit/sfRedisCacheTest.php
___________________________________________________________________
Added: svn:mime-type
+ text/x-php
Added: svn:keywords
+ Author Date Id Rev URL
Added: svn:eol-style
+ native
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.