Move test suite to the unit tests.
authorGunnar Wrobel <p@rdus.de>
Mon, 3 Jan 2011 06:36:36 +0000 (07:36 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 4 Jan 2011 07:54:20 +0000 (08:54 +0100)
framework/Kolab_Storage/test/Horde/Kolab/Storage/CacheTest.php [deleted file]
framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/CacheTest.php [new file with mode: 0644]

diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/CacheTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/CacheTest.php
deleted file mode 100644 (file)
index 905ce92..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-/**
- * Test the Kolab cache.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * Prepare the test setup.
- */
-require_once 'Autoload.php';
-
-/**
- * Test the Kolab cache.
- *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Storage
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_CacheTest extends PHPUnit_Framework_TestCase
-{
-    public function setUp()
-    {
-        $this->cache = new Horde_Cache_Storage_Mock();
-    }
-
-    /**
-     * Test cleaning the cache.
-     *
-     * @return NULL
-     */
-    public function testReset()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->reset();
-        $this->assertEquals(-1, $cache->validity);
-        $this->assertEquals(-1, $cache->nextid);
-        $this->assertTrue(empty($cache->objects));
-        $this->assertTrue(empty($cache->uids));
-    }
-
-    /**
-     * Test storing data.
-     *
-     * @return NULL
-     */
-    public function testStore()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->reset();
-        $item = array(1);
-        $cache->store(10, 1, $item);
-        $this->assertTrue(isset($cache->objects[1]));
-        $this->assertTrue(isset($cache->uids[10]));
-        $this->assertEquals(1, $cache->uids[10]);
-        $this->assertSame($item, $cache->objects[1]);
-    }
-
-    /**
-     * Test ignoring objects.
-     *
-     * @return NULL
-     */
-    public function testIgnore()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->reset();
-        $cache->ignore(11);
-        $this->assertEquals(false, $cache->uids[11]);
-    }
-
-    public function testLoadAttachment()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->storeAttachment('a', 'attachment');
-        $this->assertEquals('attachment', $cache->loadAttachment('a'));
-    }
-
-    public function testLoadSecondAttachment()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->storeAttachment('a', 'attachment');
-        $cache->storeAttachment('b', 'b');
-        $this->assertEquals('b', $cache->loadAttachment('b'));
-    }
-
-    public function testOverrideAttachment()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->storeAttachment('a', 'attachment');
-        $cache->storeAttachment('a', 'a');
-        $this->assertEquals('a', $cache->loadAttachment('a'));
-    }
-
-    public function testCachingListData()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->storeListData('user@example.com:143', 'folders', array('a', 'b'));
-        $this->assertEquals(array('a', 'b'), $cache->loadListData('user@example.com:143', 'folders'));
-    }
-
-    /**
-     * Test loading/saving the cache.
-     *
-     * @return NULL
-     */
-    public function testLoadSave()
-    {
-        $cache = new Horde_Kolab_Storage_Cache($this->cache);
-        $cache->load('test', 1);
-        /**
-         * Loading a second time should return immediately (see code
-         * coverage)
-         */
-        $cache->load('test', 1);
-        $cache->expire();
-        $this->assertEquals(-1, $cache->validity);
-        $this->assertEquals(-1, $cache->nextid);
-        $this->assertTrue(empty($cache->objects));
-        $this->assertTrue(empty($cache->uids));
-        $item1 = array(1);
-        $item2 = array(2);
-        $cache->store(10, 1, $item1);
-        $cache->store(12, 2, $item2);
-        $cache->ignore(11);
-        $this->assertTrue(isset($cache->objects[1]));
-        $this->assertTrue(isset($cache->uids[10]));
-        $this->assertEquals(1, $cache->uids[10]);
-        $this->assertEquals($item1, $cache->objects[1]);
-        $cache->save();
-        $this->assertEquals(false, $cache->uids[11]);
-        $cache->ignore(10);
-        $cache->ignore(12);
-        $this->assertEquals(false, $cache->uids[10]);
-        $this->assertEquals(false, $cache->uids[12]);
-        /** Allow us to reload the cache */
-        $cache->load('test', 1, true);
-        $this->assertTrue(isset($cache->objects[1]));
-        $this->assertTrue(isset($cache->uids[10]));
-        $this->assertEquals(1, $cache->uids[10]);
-        $this->assertEquals($item1, $cache->objects[1]);
-        $cache->expire();
-        $this->assertEquals(-1, $cache->validity);
-        $this->assertEquals(-1, $cache->nextid);
-        $this->assertTrue(empty($cache->objects));
-        $this->assertTrue(empty($cache->uids));
-    }
-
-}
diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/CacheTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/CacheTest.php
new file mode 100644 (file)
index 0000000..b3e5d22
--- /dev/null
@@ -0,0 +1,163 @@
+<?php
+/**
+ * Test the Kolab cache.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../Autoload.php';
+
+/**
+ * Test the Kolab cache.
+ *
+ * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_CacheTest
+extends Horde_Kolab_Storage_TestCase
+{
+    public function setUp()
+    {
+        $this->cache = new Horde_Cache_Storage_Mock();
+    }
+
+    /**
+     * Test cleaning the cache.
+     *
+     * @return NULL
+     */
+    public function testReset()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->reset();
+        $this->assertEquals(-1, $cache->validity);
+        $this->assertEquals(-1, $cache->nextid);
+        $this->assertTrue(empty($cache->objects));
+        $this->assertTrue(empty($cache->uids));
+    }
+
+    /**
+     * Test storing data.
+     *
+     * @return NULL
+     */
+    public function testStore()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->reset();
+        $item = array(1);
+        $cache->store(10, 1, $item);
+        $this->assertTrue(isset($cache->objects[1]));
+        $this->assertTrue(isset($cache->uids[10]));
+        $this->assertEquals(1, $cache->uids[10]);
+        $this->assertSame($item, $cache->objects[1]);
+    }
+
+    /**
+     * Test ignoring objects.
+     *
+     * @return NULL
+     */
+    public function testIgnore()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->reset();
+        $cache->ignore(11);
+        $this->assertEquals(false, $cache->uids[11]);
+    }
+
+    public function testLoadAttachment()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->storeAttachment('a', 'attachment');
+        $this->assertEquals('attachment', $cache->loadAttachment('a'));
+    }
+
+    public function testLoadSecondAttachment()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->storeAttachment('a', 'attachment');
+        $cache->storeAttachment('b', 'b');
+        $this->assertEquals('b', $cache->loadAttachment('b'));
+    }
+
+    public function testOverrideAttachment()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->storeAttachment('a', 'attachment');
+        $cache->storeAttachment('a', 'a');
+        $this->assertEquals('a', $cache->loadAttachment('a'));
+    }
+
+    public function testCachingListData()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->storeListData('user@example.com:143', 'folders', array('a', 'b'));
+        $this->assertEquals(array('a', 'b'), $cache->loadListData('user@example.com:143', 'folders'));
+    }
+
+    /**
+     * Test loading/saving the cache.
+     *
+     * @return NULL
+     */
+    public function testLoadSave()
+    {
+        $cache = new Horde_Kolab_Storage_Cache($this->cache);
+        $cache->load('test', 1);
+        /**
+         * Loading a second time should return immediately (see code
+         * coverage)
+         */
+        $cache->load('test', 1);
+        $cache->expire();
+        $this->assertEquals(-1, $cache->validity);
+        $this->assertEquals(-1, $cache->nextid);
+        $this->assertTrue(empty($cache->objects));
+        $this->assertTrue(empty($cache->uids));
+        $item1 = array(1);
+        $item2 = array(2);
+        $cache->store(10, 1, $item1);
+        $cache->store(12, 2, $item2);
+        $cache->ignore(11);
+        $this->assertTrue(isset($cache->objects[1]));
+        $this->assertTrue(isset($cache->uids[10]));
+        $this->assertEquals(1, $cache->uids[10]);
+        $this->assertEquals($item1, $cache->objects[1]);
+        $cache->save();
+        $this->assertEquals(false, $cache->uids[11]);
+        $cache->ignore(10);
+        $cache->ignore(12);
+        $this->assertEquals(false, $cache->uids[10]);
+        $this->assertEquals(false, $cache->uids[12]);
+        /** Allow us to reload the cache */
+        $cache->load('test', 1, true);
+        $this->assertTrue(isset($cache->objects[1]));
+        $this->assertTrue(isset($cache->uids[10]));
+        $this->assertEquals(1, $cache->uids[10]);
+        $this->assertEquals($item1, $cache->objects[1]);
+        $cache->expire();
+        $this->assertEquals(-1, $cache->validity);
+        $this->assertEquals(-1, $cache->nextid);
+        $this->assertTrue(empty($cache->objects));
+        $this->assertTrue(empty($cache->uids));
+    }
+
+}