From 9cd30d599e11a37d74146158ee928a627fcd80a5 Mon Sep 17 00:00:00 2001 From: knut <> Date: Mon, 11 Jun 2007 13:07:43 +0000 Subject: added some caching tests --- tests/unit/Caching/TAPCCacheTest.php | 72 +++++++++++++++++++++++++++++ tests/unit/Caching/TSqliteCacheTest.php | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tests/unit/Caching/TAPCCacheTest.php create mode 100644 tests/unit/Caching/TSqliteCacheTest.php (limited to 'tests') diff --git a/tests/unit/Caching/TAPCCacheTest.php b/tests/unit/Caching/TAPCCacheTest.php new file mode 100644 index 00000000..2bf1d5d3 --- /dev/null +++ b/tests/unit/Caching/TAPCCacheTest.php @@ -0,0 +1,72 @@ +app = new TApplication($basePath); + self::$cache = new TAPCCache(); + 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('key', 'value'); + self::assertEquals('value', self::$cache->get('key')); + } + + public function testDelete() { + self::$cache->delete('key'); + self::assertEquals(false, self::$cache->get('key')); + } + + public function testFlush() { + $this->testAdd(); + self::assertEquals(true, self::$cache->flush()); + } + +} + +?> diff --git a/tests/unit/Caching/TSqliteCacheTest.php b/tests/unit/Caching/TSqliteCacheTest.php new file mode 100644 index 00000000..59e74420 --- /dev/null +++ b/tests/unit/Caching/TSqliteCacheTest.php @@ -0,0 +1,80 @@ +init(null); + } + + } + } + + protected function tearDown() { + /*Prado::setApplication(null); + self::$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 testDbFile() { + self::assertEquals('sqlite.cache', basename(self::$cache->DbFile)); + } + + public function testSetAndGet() { + self::$cache->set('key', 'value'); + self::assertEquals('value', self::$cache->get('key')); + } + + public function testAdd() { + self::$cache->add('key', 'value'); + self::assertEquals('value', self::$cache->get('key')); + } + + public function testDelete() { + self::$cache->delete('key'); + self::assertEquals(false, self::$cache->get('key')); + } + + public function testFlush() { + $this->testAdd(); + self::assertEquals(true, self::$cache->flush()); + } + +} + +?> -- cgit v1.2.3