From: Gunnar Wrobel
Date: Tue, 4 Jan 2011 06:00:41 +0000 (+0100)
Subject: No decorator.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7c963f44ea00118c1afc4d532e3dd97697ba8f58;p=horde.git
No decorator.
---
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php
new file mode 100644
index 000000000..86c43c3e2
--- /dev/null
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php
@@ -0,0 +1,136 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The cached list query.
+ *
+ * Copyright 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_List_Query_Cache
+implements Horde_Kolab_Storage_List_Query
+{
+ /** The folder type list */
+ const TYPES = 'TYPES';
+
+ /** The folder list sorted by type */
+ const BY_TYPE = 'BY_TYPE';
+
+ /**
+ * The queriable list.
+ *
+ * @var Horde_Kolab_Storage_List
+ */
+ private $_list;
+
+ /**
+ * The list cache.
+ *
+ * @var Horde_Kolab_Storage_Cache_List
+ */
+ private $_list_cache;
+
+ /**
+ * The factory for generating additional resources.
+ *
+ * @var Horde_Kolab_Storage_Factory
+ */
+ private $_factory;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Storage_List $list The queriable list.
+ * @param Horde_Kolab_Storage_Factory $factory The factory.
+ * @param Horde_Kolab_Storage_Cache_List $list_cache The list cache.
+ */
+ public function __construct(
+ Horde_Kolab_Storage_List $list,
+ Horde_Kolab_Storage_Factory $factory,
+ Horde_Kolab_Storage_Cache_List $list_cache
+ ) {
+ $this->_list = $list;
+ $this->_list_cache = $list_cache;
+ $this->_factory = $factory;
+ }
+
+ /**
+ * Returns the folder types as associative array.
+ *
+ * @return array The list folder types with the folder names as key and the
+ * type as values.
+ */
+ public function listTypes()
+ {
+ return $this->_list_cache->getQuery(self::TYPES);
+ }
+
+ /**
+ * Returns the folder type annotation as associative array.
+ *
+ * @return array The list folder types with the folder names as key and the
+ * type handler as values.
+ */
+ public function listFolderTypeAnnotations()
+ {
+ $result = array();
+ $list = $this->_list_cache->getFolderTypes();
+ foreach ($list as $folder => $annotation) {
+ $result[$folder] = $this->_factory->createFolderType($annotation);
+ }
+ return $result;
+ }
+
+ /**
+ * List all folders of a specific type.
+ *
+ * @param string $type The folder type the listing should be limited to.
+ *
+ * @return array The list of folders.
+ */
+ public function listByType($type)
+ {
+ $by_type = $this->_list_cache->getQuery(self::BY_TYPE);
+ if (isset($by_type[$type])) {
+ return $by_type[$type];
+ } else {
+ return array();
+ }
+ }
+
+ /**
+ * Synchronize the query data with the information from the backend.
+ *
+ * @return NULL
+ */
+ public function synchronize()
+ {
+ $types = array();
+ $by_type = array();
+ foreach ($this->listFolderTypeAnnotations() as $folder => $annotation) {
+ $type = $annotation->getType();
+ $types[$folder] = $type;
+ $by_type[$type][] = $folder;
+ }
+ $this->_list_cache->setQuery(self::TYPES, $types);
+ $this->_list_cache->setQuery(self::BY_TYPE, $by_type);
+ }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Decorator/Cache.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Decorator/Cache.php
deleted file mode 100644
index 3fc2c87df..000000000
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Decorator/Cache.php
+++ /dev/null
@@ -1,136 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Storage
- */
-
-/**
- * The cached list query.
- *
- * Copyright 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_List_Query_Decorator_Cache
-implements Horde_Kolab_Storage_List_Query
-{
- /** The folder type list */
- const TYPES = 'TYPES';
-
- /** The folder list sorted by type */
- const BY_TYPE = 'BY_TYPE';
-
- /**
- * The queriable list.
- *
- * @var Horde_Kolab_Storage_List
- */
- private $_list;
-
- /**
- * The list cache.
- *
- * @var Horde_Kolab_Storage_Cache_List
- */
- private $_list_cache;
-
- /**
- * The factory for generating additional resources.
- *
- * @var Horde_Kolab_Storage_Factory
- */
- private $_factory;
-
- /**
- * Constructor.
- *
- * @param Horde_Kolab_Storage_List $list The queriable list.
- * @param Horde_Kolab_Storage_Factory $factory The factory.
- * @param Horde_Kolab_Storage_Cache_List $list_cache The list cache.
- */
- public function __construct(
- Horde_Kolab_Storage_List $list,
- Horde_Kolab_Storage_Factory $factory,
- Horde_Kolab_Storage_Cache_List $list_cache
- ) {
- $this->_list = $list;
- $this->_list_cache = $list_cache;
- $this->_factory = $factory;
- }
-
- /**
- * Returns the folder types as associative array.
- *
- * @return array The list folder types with the folder names as key and the
- * type as values.
- */
- public function listTypes()
- {
- return $this->_list_cache->getQuery(self::TYPES);
- }
-
- /**
- * Returns the folder type annotation as associative array.
- *
- * @return array The list folder types with the folder names as key and the
- * type handler as values.
- */
- public function listFolderTypeAnnotations()
- {
- $result = array();
- $list = $this->_list_cache->getFolderTypes();
- foreach ($list as $folder => $annotation) {
- $result[$folder] = $this->_factory->createFolderType($annotation);
- }
- return $result;
- }
-
- /**
- * List all folders of a specific type.
- *
- * @param string $type The folder type the listing should be limited to.
- *
- * @return array The list of folders.
- */
- public function listByType($type)
- {
- $by_type = $this->_list_cache->getQuery(self::BY_TYPE);
- if (isset($by_type[$type])) {
- return $by_type[$type];
- } else {
- return array();
- }
- }
-
- /**
- * Synchronize the query data with the information from the backend.
- *
- * @return NULL
- */
- public function synchronize()
- {
- $types = array();
- $by_type = array();
- foreach ($this->listFolderTypeAnnotations() as $folder => $annotation) {
- $type = $annotation->getType();
- $types[$folder] = $type;
- $by_type[$type][] = $folder;
- }
- $this->_list_cache->setQuery(self::TYPES, $types);
- $this->_list_cache->setQuery(self::BY_TYPE, $by_type);
- }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Storage/package.xml b/framework/Kolab_Storage/package.xml
index 79a145163..996da58e9 100644
--- a/framework/Kolab_Storage/package.xml
+++ b/framework/Kolab_Storage/package.xml
@@ -31,8 +31,8 @@
jan@horde.org
yes
- 2011-01-03
-
+ 2011-01-04
+
0.4.0
0.1.0
@@ -145,10 +145,8 @@
-
-
-
+
@@ -469,6 +467,7 @@
+
@@ -633,7 +632,7 @@
-
+
@@ -753,6 +752,7 @@
+
@@ -824,7 +824,7 @@
alpha
alpha
- 2011-01-03
+ 2011-01-04
LGPL
* Added namespace support (Bug #6691).
diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/TestCase.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/TestCase.php
index 43eb2b911..835dd67e9 100644
--- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/TestCase.php
+++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/TestCase.php
@@ -195,7 +195,7 @@ extends PHPUnit_Framework_TestCase
$bare_list,
$list_cache
);
- $query = new Horde_Kolab_Storage_List_Query_Decorator_Cache(
+ $query = new Horde_Kolab_Storage_List_Query_Cache(
$list,
$factory,
$list_cache
diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php
new file mode 100644
index 000000000..0be91df6f
--- /dev/null
+++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php
@@ -0,0 +1,97 @@
+
+ * @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 cached list query.
+ *
+ * Copyright 2011 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
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Unit_List_Query_CacheTest
+extends Horde_Kolab_Storage_TestCase
+{
+ public function testAnotationsReturnsArray()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
+ $this->assertType('array', $query->listFolderTypeAnnotations());
+ }
+
+ public function testAnnotationsReturnsHandlers()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
+ foreach ($query->listFolderTypeAnnotations() as $folder => $type) {
+ $this->assertInstanceOf('Horde_Kolab_Storage_Folder_Type', $type);
+ };
+ }
+
+ public function testTypeReturnsArray()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
+ $this->assertType('array', $query->listTypes());
+ }
+
+ public function testTypeReturnsAnnotations()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
+ $this->assertEquals(
+ array(
+ 'INBOX/Calendar' => 'event',
+ 'INBOX/Contacts' => 'contact',
+ 'INBOX/Notes' => 'note',
+ 'INBOX/Tasks' => 'task',
+ ),
+ $query->listTypes()
+ );
+ }
+
+ public function testByTypeReturnsArray()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
+ $this->assertType('array', $query->listByType('test'));
+ }
+
+ public function testListCalendarsListsCalendars()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
+ $this->assertEquals(array('INBOX/Calendar'), $query->listByType('event'));
+ }
+
+ public function testListTasklistsListsTasklists()
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
+ $this->assertEquals(array('INBOX/Tasks'), $query->listByType('task'));
+ }
+
+}
diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/Decorator/CacheTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/Decorator/CacheTest.php
deleted file mode 100644
index 22e1265a4..000000000
--- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/Decorator/CacheTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-
- * @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 cached list query.
- *
- * Copyright 2011 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
- * @subpackage UnitTests
- * @author Gunnar Wrobel
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Storage
- */
-class Horde_Kolab_Storage_Unit_List_Query_Decorator_CacheTest
-extends Horde_Kolab_Storage_TestCase
-{
- public function testAnotationsReturnsArray()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
- $this->assertType('array', $query->listFolderTypeAnnotations());
- }
-
- public function testAnnotationsReturnsHandlers()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
- foreach ($query->listFolderTypeAnnotations() as $folder => $type) {
- $this->assertInstanceOf('Horde_Kolab_Storage_Folder_Type', $type);
- };
- }
-
- public function testTypeReturnsArray()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
- $this->assertType('array', $query->listTypes());
- }
-
- public function testTypeReturnsAnnotations()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
- $this->assertEquals(
- array(
- 'INBOX/Calendar' => 'event',
- 'INBOX/Contacts' => 'contact',
- 'INBOX/Notes' => 'note',
- 'INBOX/Tasks' => 'task',
- ),
- $query->listTypes()
- );
- }
-
- public function testByTypeReturnsArray()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getNullList($factory), $factory);
- $this->assertType('array', $query->listByType('test'));
- }
-
- public function testListCalendarsListsCalendars()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
- $this->assertEquals(array('INBOX/Calendar'), $query->listByType('event'));
- }
-
- public function testListTasklistsListsTasklists()
- {
- $factory = new Horde_Kolab_Storage_Factory();
- $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory);
- $this->assertEquals(array('INBOX/Tasks'), $query->listByType('task'));
- }
-
-}