summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorcarl <>2007-07-26 16:01:17 +0000
committercarl <>2007-07-26 16:01:17 +0000
commitbb0f7a0f25545b067d796d2eeeecb19901abdd5f (patch)
tree32255c16eb5c6f553c384ac9d1bfdae33cd5c7c3 /tests
parent01997bcbaa545654111d88e2386c54087b5a2ce8 (diff)
#623 - MemCache to support multiple servers
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Caching/AllTests.php2
-rw-r--r--tests/unit/Caching/TMemCacheTest.php72
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/unit/Caching/AllTests.php b/tests/unit/Caching/AllTests.php
index 555a4344..641311db 100644
--- a/tests/unit/Caching/AllTests.php
+++ b/tests/unit/Caching/AllTests.php
@@ -7,6 +7,7 @@ if(!defined('PHPUnit_MAIN_METHOD')) {
require_once 'TSqliteCacheTest.php';
require_once 'TAPCCacheTest.php';
+require_once 'TMemCacheTest.php';
class Caching_AllTests {
public static function main() {
@@ -18,6 +19,7 @@ class Caching_AllTests {
$suite->addTestSuite('TSqliteCacheTest');
$suite->addTestSuite('TAPCCacheTest');
+ $suite->addTestSuite('TMemCacheTest');
return $suite;
}
diff --git a/tests/unit/Caching/TMemCacheTest.php b/tests/unit/Caching/TMemCacheTest.php
new file mode 100644
index 00000000..bafae6cf
--- /dev/null
+++ b/tests/unit/Caching/TMemCacheTest.php
@@ -0,0 +1,72 @@
+<?php
+require_once dirname(__FILE__).'/../phpunit.php';
+
+Prado::using('System.Caching.TMemCache');
+
+/**
+ * @package System.Caching
+ */
+class TMemCacheTest extends PHPUnit_Framework_TestCase {
+
+ protected $app = null;
+ protected static $cache = null;
+
+ protected function setUp() {
+ if(!extension_loaded('memcache')) {
+ self::markTestSkipped('The memcache extension is not available');
+ } else {
+ $basePath = dirname(__FILE__).'/mockapp';
+ $runtimePath = $basePath.'/runtime';
+ if(!is_writable($runtimePath)) {
+ self::markTestSkipped("'$runtimePath' is writable");
+ }
+ $this->app = new TApplication($basePath);
+ self::$cache = new TMemCache();
+ self::$cache->init(null);
+ }
+ }
+
+ protected function tearDown() {
+ $this->app = null;
+ $this->cache = null;
+ }
+
+ public function testInit() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testPrimaryCache() {
+ self::$cache->PrimaryCache = true;
+ self::assertEquals(true, self::$cache->PrimaryCache);
+ self::$cache->PrimaryCache = false;
+ self::assertEquals(false, self::$cache->PrimaryCache);
+ }
+
+ public function testKeyPrefix() {
+ self::$cache->KeyPrefix = 'prefix';
+ self::assertEquals('prefix', self::$cache->KeyPrefix);
+ }
+
+ public function testSetAndGet() {
+ self::$cache->set('key', 'value');
+ self::assertEquals('value', self::$cache->get('key'));
+ }
+
+ public function testAdd() {
+ self::$cache->add('anotherkey', 'value');
+ self::assertEquals('value', self::$cache->get('anotherkey'));
+ }
+
+ public function testDelete() {
+ self::$cache->delete('key');
+ self::assertEquals(false, self::$cache->get('key'));
+ }
+
+ public function testFlush() {
+ $this->testSetAndGet();
+ self::assertEquals(true, self::$cache->flush());
+ }
+
+}
+
+?>