From a005fd6ede20332cacf84c9ab9552f12a10b38c4 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 3 Nov 2009 11:56:09 +0100 Subject: [PATCH] Reorganize interfaces and decorators. --- .../Server/{Composite.php => Composite/Base.php} | 19 +- .../lib/Horde/Kolab/Server/Composite/Interface.php | 43 ++++ .../{Connection.php => Connection/Interface.php} | 2 +- .../lib/Horde/Kolab/Server/Connection/Mock.php | 2 +- .../Horde/Kolab/Server/Connection/Mock/Ldap.php | 10 +- .../Horde/Kolab/Server/Connection/Simpleldap.php | 2 +- .../Horde/Kolab/Server/Connection/Splittedldap.php | 2 +- .../Server/{Cleaner.php => Decorator/Clean.php} | 20 +- .../lib/Horde/Kolab/Server/Decorator/Count.php | 283 +++++++++++++++++++++ .../Kolab/Server/{Logged.php => Decorator/Log.php} | 21 +- .../Kolab/Server/{Mapped.php => Decorator/Map.php} | 21 +- .../lib/Horde/Kolab/Server/Factory/Base.php | 6 +- .../Horde/Kolab/Server/Factory/Configuration.php | 10 +- .../Server/Factory/{Conn => Connection}/Base.php | 4 +- .../Factory/{Conn => Connection}/Configuration.php | 8 +- .../Factory/{Conn => Connection}/Injector.php | 6 +- .../Factory/{Conn.php => Connection/Interface.php} | 2 +- .../Server/Factory/{Conn => Connection}/Ldap.php | 4 +- .../Server/Factory/{Conn => Connection}/Mock.php | 4 +- .../lib/Horde/Kolab/Server/Factory/Constructor.php | 6 +- .../Factory/{Cleaner.php => Decorator/Clean.php} | 11 +- .../Horde/Kolab/Server/Factory/Decorator/Count.php | 156 ++++++++++++ .../Factory/{Logged.php => Decorator/Log.php} | 12 +- .../Factory/{Mapped.php => Decorator/Map.php} | 10 +- .../lib/Horde/Kolab/Server/Factory/Injector.php | 49 ++-- .../Server/{Factory.php => Factory/Interface.php} | 2 +- .../Kolab/{Server.php => Server/Interface.php} | 12 +- .../Kolab_Server/lib/Horde/Kolab/Server/Ldap.php | 17 +- .../lib/Horde/Kolab/Server/Ldap/Changes.php | 6 +- .../lib/Horde/Kolab/Server/Ldap/Filtered.php | 2 +- .../lib/Horde/Kolab/Server/Ldap/Standard.php | 2 +- .../Kolab/Server/{List.php => List/Interface.php} | 0 .../Horde/Kolab/Server/Object/Attribute/Base.php | 8 +- .../Kolab/Server/Object/Attribute/Decorator.php | 4 +- .../{Attribute.php => Attribute/Interface.php} | 2 +- .../Kolab/Server/Object/Attribute/Objectclass.php | 4 +- .../lib/Horde/Kolab/Server/Object/Base.php | 4 +- .../lib/Horde/Kolab/Server/Object/Factory.php | 13 +- .../lib/Horde/Kolab/Server/Object/Groupofnames.php | 73 +----- .../lib/Horde/Kolab/Server/Object/Hash.php | 2 +- .../Horde/Kolab/Server/Object/Inetorgperson.php | 198 +++++++------- .../Server/{Object.php => Object/Interface.php} | 2 +- .../lib/Horde/Kolab/Server/Object/Kolab/User.php | 18 +- .../Kolab/Server/Object/Kolabinetorgperson.php | 120 ++++----- .../lib/Horde/Kolab/Server/Object/Mcached.php | 2 +- .../Kolab/Server/Object/Organizationalperson.php | 52 ++-- .../lib/Horde/Kolab/Server/Objects/Base.php | 12 +- .../Server/{Objects.php => Objects/Interface.php} | 6 +- .../lib/Horde/Kolab/Server/Query/Element/And.php | 5 +- .../Horde/Kolab/Server/Query/Element/Approx.php | 5 +- .../Horde/Kolab/Server/Query/Element/Begins.php | 5 +- .../Horde/Kolab/Server/Query/Element/Contains.php | 5 +- .../lib/Horde/Kolab/Server/Query/Element/Ends.php | 5 +- .../Horde/Kolab/Server/Query/Element/Equals.php | 5 +- .../Horde/Kolab/Server/Query/Element/Greater.php | 5 +- .../lib/Horde/Kolab/Server/Query/Element/Group.php | 2 +- .../Query/{Element.php => Element/Interface.php} | 7 +- .../lib/Horde/Kolab/Server/Query/Element/Less.php | 5 +- .../Horde/Kolab/Server/Query/Element/Mapped.php | 11 +- .../lib/Horde/Kolab/Server/Query/Element/Not.php | 9 +- .../lib/Horde/Kolab/Server/Query/Element/Or.php | 5 +- .../Horde/Kolab/Server/Query/Element/Single.php | 2 +- .../Server/{Query.php => Query/Interface.php} | 2 +- .../lib/Horde/Kolab/Server/Query/Ldap.php | 9 +- .../Server/{Result.php => Result/Interface.php} | 2 +- .../lib/Horde/Kolab/Server/Result/Ldap.php | 3 +- .../lib/Horde/Kolab/Server/Schema/Base.php | 20 +- .../Horde/Kolab/Server/Schema/Decorator/Cache.php | 280 ++++++++++++++++++++ .../Server/{Schema.php => Schema/Interface.php} | 10 +- .../lib/Horde/Kolab/Server/Search/Base.php | 5 +- .../lib/Horde/Kolab/Server/Search/Interface.php | 4 +- .../Horde/Kolab/Server/Search/Operation/Base.php | 5 +- .../Server/Search/Operation/Groupsformember.php | 47 ++++ .../Horde/Kolab/Server/Search/Operation/Guid.php | 5 +- .../Server/Search/Operation/Restrictgroups.php | 54 ++++ .../lib/Horde/Kolab/Server/Structure/Base.php | 9 +- .../lib/Horde/Kolab/Server/Structure/Interface.php | 10 +- .../lib/Horde/Kolab/Server/Structure/Kolab.php | 3 +- .../lib/Horde/Kolab/Server/Structure/Ldap.php | 2 +- framework/Kolab_Server/package.xml | 114 +++++---- .../{CompositeTest.php => Composite/BaseTest.php} | 10 +- .../{CleanerTest.php => Decorator/CleanTest.php} | 28 +- .../{LoggedTest.php => Decorator/LogTest.php} | 24 +- .../Class/Server/Factory/ConfigurationTest.php | 24 +- .../{Conn => Connection}/ConfigurationTest.php | 12 +- .../Factory/{Conn => Connection}/InjectorTest.php | 10 +- .../Factory/{Conn => Connection}/LdapTest.php | 14 +- .../Factory/{Conn => Connection}/MockTest.php | 10 +- .../Class/Server/Factory/ConstructorTest.php | 32 ++- .../{CleanerTest.php => Decorator/CleanTest.php} | 51 ++-- .../{LoggedTest.php => Decorator/LogTest.php} | 48 ++-- .../{MappedTest.php => Decorator/MapTest.php} | 49 ++-- .../Server/Class/Server/Factory/InjectorTest.php | 12 +- .../Server/Class/Server/Factory/KolabTest.php | 12 +- .../Kolab/Server/Class/Server/Ldap/ChangesTest.php | 20 +- .../Horde/Kolab/Server/Class/Server/LdapTest.php | 32 +-- .../Class/Server/Object/Attribute/BaseTest.php | 9 +- .../Kolab/Server/Class/Server/Object/BaseTest.php | 34 +-- .../Kolab/Server/Class/Server/Query/LdapTest.php | 25 +- .../Class/Server/Search/Operation/GuidTest.php | 16 +- .../Server/Class/Server/Structure/KolabTest.php | 18 +- .../Server/Class/Server/Structure/LdapTest.php | 10 +- .../test/Horde/Kolab/Server/TestCase.php | 24 +- 103 files changed, 1693 insertions(+), 765 deletions(-) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Composite.php => Composite/Base.php} (86%) create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Connection.php => Connection/Interface.php} (95%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Cleaner.php => Decorator/Clean.php} (94%) create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Logged.php => Decorator/Log.php} (95%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Mapped.php => Decorator/Map.php} (95%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn => Connection}/Base.php (92%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn => Connection}/Configuration.php (94%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn => Connection}/Injector.php (90%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn.php => Connection/Interface.php} (95%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn => Connection}/Ldap.php (96%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Conn => Connection}/Mock.php (93%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Cleaner.php => Decorator/Clean.php} (93%) create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Logged.php => Decorator/Log.php} (93%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/{Mapped.php => Decorator/Map.php} (93%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Factory.php => Factory/Interface.php} (98%) rename framework/Kolab_Server/lib/Horde/Kolab/{Server.php => Server/Interface.php} (95%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{List.php => List/Interface.php} (100%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Object/{Attribute.php => Attribute/Interface.php} (97%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Object.php => Object/Interface.php} (98%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Objects.php => Objects/Interface.php} (96%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/Query/{Element.php => Element/Interface.php} (90%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Query.php => Query/Interface.php} (98%) rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Result.php => Result/Interface.php} (96%) create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php rename framework/Kolab_Server/lib/Horde/Kolab/Server/{Schema.php => Schema/Interface.php} (90%) create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php create mode 100644 framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/{CompositeTest.php => Composite/BaseTest.php} (81%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/{CleanerTest.php => Decorator/CleanTest.php} (88%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/{LoggedTest.php => Decorator/LogTest.php} (90%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{Conn => Connection}/ConfigurationTest.php (82%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{Conn => Connection}/InjectorTest.php (79%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{Conn => Connection}/LdapTest.php (87%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{Conn => Connection}/MockTest.php (86%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{CleanerTest.php => Decorator/CleanTest.php} (69%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{LoggedTest.php => Decorator/LogTest.php} (70%) rename framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/{MappedTest.php => Decorator/MapTest.php} (70%) diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php similarity index 86% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php index 78bec71ea..369b530cc 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php @@ -25,40 +25,41 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Composite +class Horde_Kolab_Server_Composite_Base +implements Horde_Kolab_Server_Composite_Interface { /** * The server. * - * @var Horde_Kolab_Server + * @var Horde_Kolab_Server_Interface */ private $_server; /** * The structure handler for this server. * - * @var Horde_Kolab_Server_Structure + * @var Horde_Kolab_Server_Structure_Interface */ private $_structure; /** * The search handler for this server. * - * @var Horde_Kolab_Server_Search + * @var Horde_Kolab_Server_Search_Interface */ private $_search; /** * The object handler for this server. * - * @var Horde_Kolab_Server_Objects + * @var Horde_Kolab_Server_Objects_Interface */ private $_objects; /** * The schema handler for this server. * - * @var Horde_Kolab_Server_Schema + * @var Horde_Kolab_Server_Schema_Interface */ private $_schema; @@ -68,11 +69,11 @@ class Horde_Kolab_Server_Composite * @param array $params Parameter array. */ public function __construct( - Horde_Kolab_Server $server, - Horde_Kolab_Server_Objects $objects, + Horde_Kolab_Server_Interface $server, + Horde_Kolab_Server_Objects_Interface $objects, Horde_Kolab_Server_Structure_Interface $structure, Horde_Kolab_Server_Search_Interface $search, - Horde_Kolab_Server_Schema $schema + Horde_Kolab_Server_Schema_Interface $schema ) { $this->_server = $server; $this->_objects = $objects; diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php new file mode 100644 index 000000000..6016b4a99 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php @@ -0,0 +1,43 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Marks composite server instances. + * + * Copyright 2008-2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Composite_Interface +{ + /** + * Connect to the server. Use this method if the user name you can provide + * does not match a DN. In this case it will be required to map this user + * name first. + * + * @param string $user The user name. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connect($user = null, $pass = null); +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php similarity index 95% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php index 2da34a2fe..b9e868972 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Connection +interface Horde_Kolab_Server_Connection_Interface { /** * Get the server read connection. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php index e78597fea..c3b8b9911 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Mock -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * The LDAP connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php index c97c6718a..ac08fe94e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php @@ -88,13 +88,13 @@ class Horde_Kolab_Server_Connection_Mock_Ldap throw new Horde_Kolab_Server_Exception('User does not exist!'); } - if (!isset($this->_data[$dn]['userPassword'][0])) { + if (!isset($this->_data[$dn]['data']['userPassword'][0])) { throw new Horde_Kolab_Server_Exception('User has no password entry!'); } - if ($this->_data[$dn]['userPassword'][0] != $pw) { + if ($this->_data[$dn]['data']['userPassword'][0] != $pw) { throw new Horde_Kolab_Server_Exception('Incorrect password!'); } - } else if (!empty($this->params_['no_anonymous_bind'])) { + } else if (!empty($this->_params['no_anonymous_bind'])) { throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!'); } @@ -163,7 +163,7 @@ class Horde_Kolab_Server_Connection_Mock_Ldap if (isset($params['scope'])) { if ($params['scope'] == 'base') { if (isset($this->_data[$base])) { - $result = $this->_data[$base]; + $result[] = $this->_data[$base]; } else { $result = array(); } @@ -213,7 +213,7 @@ class Horde_Kolab_Server_Connection_Mock_Ldap if (!empty($base)) { $subtree = array(); foreach ($result as $entry) { - if (strpos($entry['dn'], $base)) { + if (strpos($entry['dn'], $base) !== false) { $subtree[] = $entry; } } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php index 73c903f20..b308ed907 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Simpleldap -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * The LDAP connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php index b5781a7f1..7fb687238 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Splittedldap -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * LDAP read connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php similarity index 94% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php index 9df64e515..5352d747b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php @@ -27,7 +27,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Cleaner implements Horde_Kolab_Server +class Horde_Kolab_Server_Decorator_Clean +implements Horde_Kolab_Server_Interface { /** * The server we delegate to. @@ -48,8 +49,9 @@ class Horde_Kolab_Server_Cleaner implements Horde_Kolab_Server * * @param Horde_Kolab_Server $server The base server connection. */ - public function __construct(Horde_Kolab_Server $server) - { + public function __construct( + Horde_Kolab_Server_Interface $server + ) { $this->_server = $server; } @@ -163,8 +165,10 @@ class Horde_Kolab_Server_Cleaner implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $this->_server->save($object, $data); } @@ -179,8 +183,10 @@ class Horde_Kolab_Server_Cleaner implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $this->_server->add($object, $data); $this->_added[] = $object->getGuid(); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php new file mode 100644 index 000000000..712110b17 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php @@ -0,0 +1,283 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A server decorator that counts the number of database calls and + * reports them via a logger. + * + * Copyright 2008-2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Decorator_Count +implements Horde_Kolab_Server_Interface +{ + /** + * The server we delegate to. + * + * @var Horde_Kolab_Server + */ + private $_server; + + /** + * The log handler. + * + * @var Horde_Log_Logger + */ + private $_logger; + + /** + * The statistic. + * + * @var array + */ + private $_count = array(); + + /** + * Constructor. + * + * @param Horde_Kolab_Server $server The base server connection. + * @param mixed $logger The log handler. The class must at + * least provide the info() method. + */ + public function __construct( + Horde_Kolab_Server_Interface $server, + $logger + ) { + $this->_server = $server; + $this->_logger = $logger; + } + + /** + * Destructor. + * + * Logs the counted events. + */ + public function __destruct() + { + foreach ($this->_count as $method => $count) { + $this->_logger->info( + sprintf( + 'Horde_Kolab_Server: Method %s called %s times.', + $method, $count + ) + ); + } + } + + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = null, $pass = null) + { + $this->_server->connectGuid($guid, $pass); + $this->_count['connectGuid']++; + } + + /** + * Get the current GUID + * + * @return string The GUID of the connected user. + */ + public function getGuid() + { + return $this->_server->getGuid(); + } + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid() + { + return $this->_server->getBaseGuid(); + } + + /** + * Low level access to reading object data. + * + * @param string $guid The object to retrieve. + * @param array $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception If the search operation hit an error + * or returned no result. + */ + public function read($guid, array $attrs = array()) + { + return $this->_server->read($guid); + $this->_count['read']++; + } + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs) + { + return $this->_server->readAttributes($guid, $attrs); + $this->_count['readAttributes']++; + } + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()) + { + return $this->_server->find($query, $params); + $this->_count['find']++; + } + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()) + { + return $this->_server->findBelow($query, $parent, $params); + $this->_count['findBelow']++; + } + + /** + * Modify existing object data. + * + * @param Horde_Kolab_Server_Object $object The object to be modified. + * @param array $data The attributes of the object + * to be stored. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->save($object, $data); + $this->_count['save']++; + } + + /** + * Add new object data. + * + * @param Horde_Kolab_Server_Object $object The object to be added. + * @param array $data The attributes of the object + * to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->add($object, $data); + $this->_count['add']++; + } + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid) + { + $this->_server->delete($guid); + $this->_count['delete']++; + } + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new) + { + $this->_server->rename($guid, $new); + $this->_count['rename']++; + } + + /** + * Return the ldap schema. + * + * @return Net_LDAP2_Schema The LDAP schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema() + { + return $this->_server->getSchema(); + $this->_count['getSchema']++; + } + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid) + { + return $this->_server->getParentGuid($guid); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php similarity index 95% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php index c71e5f56e..8d9490028 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Logged implements Horde_Kolab_Server +class Horde_Kolab_Server_Decorator_Log +implements Horde_Kolab_Server_Interface { /** * The server we delegate to. @@ -48,8 +49,10 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server * @param mixed $logger The log handler. The class must at * least provide the info() method. */ - public function __construct(Horde_Kolab_Server $server, $logger) - { + public function __construct( + Horde_Kolab_Server_Interface $server, + $logger + ) { $this->_server = $server; $this->_logger = $logger; } @@ -179,8 +182,10 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { try { $this->_server->save($object, $data); $this->_logger->info( @@ -211,8 +216,10 @@ class Horde_Kolab_Server_Logged implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { try { $this->_server->add($object, $data); $this->_logger->info( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php similarity index 95% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php index f911d748b..f5ce4ff47 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server +class Horde_Kolab_Server_Decorator_Map +implements Horde_Kolab_Server_Interface { /** * The server we delegate to. @@ -47,8 +48,10 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server * @param Horde_Kolab_Server $server The base server connection. * @param array $mapping The attribute mapping. */ - public function __construct(Horde_Kolab_Server $server, array $mapping) - { + public function __construct( + Horde_Kolab_Server_Interface $server, + array $mapping + ) { $this->_server = $server; $this->_mapping = $mapping; } @@ -191,8 +194,10 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { //@todo: This will not work this way as we need to map internal // attributes. $this->mapAttributes($data); @@ -209,8 +214,10 @@ class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { //@todo: This will not work this way as we need to map internal // attributes. $this->mapAttributes($data); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php index 2f22f3d4a..5c4597efe 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Factory_Base -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * The connection factory. @@ -52,7 +52,7 @@ implements Horde_Kolab_Server_Factory * server. */ public function __construct( - Horde_Kolab_Server_Factory_Conn $factory, + Horde_Kolab_Server_Factory_Connection_Interface $factory, array $config ) { $this->_conn_factory = $factory; @@ -129,7 +129,7 @@ implements Horde_Kolab_Server_Factory */ public function getComposite() { - $composite = new Horde_Kolab_Server_Composite( + $composite = new Horde_Kolab_Server_Composite_Base( $this->getServer(), $this->getObjects(), $this->getStructure(), diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php index b031dd9be..3bf6964c2 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Factory_Configuration -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * Configuration parameters for the server. @@ -49,7 +49,7 @@ implements Horde_Kolab_Server_Factory { $this->_configuration = $config; - $connection_factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $connection_factory = new Horde_Kolab_Server_Factory_Connection_Configuration( $config ); $factory = new Horde_Kolab_Server_Factory_Kolab( @@ -57,19 +57,19 @@ implements Horde_Kolab_Server_Factory ); if (isset($config['logger'])) { - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $factory, $config['logger'] ); } if (isset($config['map'])) { - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $factory, $config['map'] ); } if (!empty($config['cleanup'])) { - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $factory ); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php similarity index 92% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php index 1336cbdff..3e1119a8e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -abstract class Horde_Kolab_Server_Factory_Conn_Base -implements Horde_Kolab_Server_Factory_Conn +abstract class Horde_Kolab_Server_Factory_Connection_Base +implements Horde_Kolab_Server_Factory_Connection_Interface { /** * Connection parameters. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php similarity index 94% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php index 6f4dba1dd..c64573e0d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Conn_Configuration -extends Horde_Kolab_Server_Factory_Conn_Base +class Horde_Kolab_Server_Factory_Connection_Configuration +extends Horde_Kolab_Server_Factory_Connection_Base { /** * Configuration parameters for the connection. @@ -72,9 +72,9 @@ extends Horde_Kolab_Server_Factory_Conn_Base $this->_configuration = $configuration; if (empty($configuration['mock'])) { - $this->_factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $this->_factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); } else { - $this->_factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $this->_factory = new Horde_Kolab_Server_Factory_Connection_Mock(); } $this->_factory->setConfiguration($configuration); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php similarity index 90% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php index 9027b9ad3..2daf7601a 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Conn_Injector -extends Horde_Kolab_Server_Factory_Conn_Base +class Horde_Kolab_Server_Factory_Connection_Injector +extends Horde_Kolab_Server_Factory_Connection_Base { /** * The injector providing our context. @@ -53,7 +53,7 @@ extends Horde_Kolab_Server_Factory_Conn_Base public function getConnection() { $factory = $this->_injector->getInstance( - 'Horde_Kolab_Server_Factory_Conn' + 'Horde_Kolab_Server_Factory_Connection_Interface' ); $factory->setConfiguration( $this->_injector->getInstance( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php similarity index 95% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php index 3e2e7d7e4..94c50f497 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Factory_Conn +interface Horde_Kolab_Server_Factory_Connection_Interface { /** * Get the connection configuration. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php similarity index 96% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php index f483de804..6bd28fd41 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Conn_Ldap -extends Horde_Kolab_Server_Factory_Conn_Base +class Horde_Kolab_Server_Factory_Connection_Ldap +extends Horde_Kolab_Server_Factory_Connection_Base { /** * Set the connection configuration. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php similarity index 93% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php index 253821143..67ec0bf9f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Conn_Mock -extends Horde_Kolab_Server_Factory_Conn_Base +class Horde_Kolab_Server_Factory_Connection_Mock +extends Horde_Kolab_Server_Factory_Connection_Base { /** * Return the server connection that should be used. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php index 0762abcf0..1d8002835 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php @@ -74,11 +74,11 @@ extends Horde_Kolab_Server_Factory_Base * server. */ public function __construct( - Horde_Kolab_Server_Factory_Conn $factory, - Horde_Kolab_Server_Objects $objects, + Horde_Kolab_Server_Factory_Connection_Interface $factory, + Horde_Kolab_Server_Objects_Interface $objects, Horde_Kolab_Server_Structure_Interface $structure, Horde_Kolab_Server_Search_Interface $search, - Horde_Kolab_Server_Schema $schema, + Horde_Kolab_Server_Schema_Interface $schema, array $config ) { parent::__construct($factory, $config); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php similarity index 93% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php index 9c791082d..7c021cc5a 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Cleaner -implements Horde_Kolab_Server_Factory +class Horde_Kolab_Server_Factory_Decorator_Clean +implements Horde_Kolab_Server_Factory_Interface { /** * The factory used for creating the instances. @@ -40,8 +40,9 @@ implements Horde_Kolab_Server_Factory * * @param Horde_Kolab_Server_Factory $factory The base factory. */ - public function __construct(Horde_Kolab_Server_Factory $factory) - { + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory + ) { $this->_factory = $factory; } @@ -73,7 +74,7 @@ implements Horde_Kolab_Server_Factory public function getServer() { $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Cleaner($server); + $server = new Horde_Kolab_Server_Decorator_Clean($server); return $server; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php new file mode 100644 index 000000000..ef7ecdeaf --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php @@ -0,0 +1,156 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds counting to the generated instances. + * + * Copyright 2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Decorator_Count +implements Horde_Kolab_Server_Factory_Interface +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * The logger. + * + * @var mixed + */ + private $_logger; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + * @param mixed $logger The logger isntance. + */ + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory, + $logger + ) { + $this->_factory = $factory; + $this->_logger = $logger; + } + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory() + { + return $this->_factory->getConnectionFactory(); + } + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration() + { + return $this->_factory->getConfiguration(); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer() + { + $server = $this->_factory->getServer(); + $server = new Horde_Kolab_Server_Decorator_Count( + $server, $this->_logger + ); + return $server; + } + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } + + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite() + { + return $this->_factory->getComposite(); + } + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects() + { + return $this->_factory->getObjects(); + } + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure() + { + return $this->_factory->getStructure(); + } + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch() + { + return $this->_factory->getSearch(); + } + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema() + { + return $this->_factory->getSchema(); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php similarity index 93% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php index b177ed3f0..f2227c37b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Logged -implements Horde_Kolab_Server_Factory +class Horde_Kolab_Server_Factory_Decorator_Log +implements Horde_Kolab_Server_Factory_Interface { /** * The factory used for creating the instances. @@ -48,8 +48,10 @@ implements Horde_Kolab_Server_Factory * @param Horde_Kolab_Server_Factory $factory The base factory. * @param mixed $logger The logger isntance. */ - public function __construct(Horde_Kolab_Server_Factory $factory, $logger) - { + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory, + $logger + ) { $this->_factory = $factory; $this->_logger = $logger; } @@ -82,7 +84,7 @@ implements Horde_Kolab_Server_Factory public function getServer() { $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Logged( + $server = new Horde_Kolab_Server_Decorator_Log( $server, $this->_logger ); return $server; diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php similarity index 93% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php index 4424405f3..2e0862302 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php @@ -25,8 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Factory_Mapped -implements Horde_Kolab_Server_Factory +class Horde_Kolab_Server_Factory_Decorator_Map +implements Horde_Kolab_Server_Factory_Interface { /** * The factory used for creating the instances. @@ -49,7 +49,7 @@ implements Horde_Kolab_Server_Factory * @param array $mapping The attribute mapping. */ public function __construct( - Horde_Kolab_Server_Factory $factory, + Horde_Kolab_Server_Factory_Interface $factory, array $mapping) { $this->_factory = $factory; @@ -84,7 +84,9 @@ implements Horde_Kolab_Server_Factory public function getServer() { $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Mapped($server, $this->_mapping); + $server = new Horde_Kolab_Server_Decorator_Map( + $server, $this->_mapping + ); return $server; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php index e3b3ba1f3..df92422e5 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Factory_Injector -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * The injector. @@ -97,7 +97,7 @@ implements Horde_Kolab_Server_Factory Horde_Injector $injector ) { $injector->bindImplementation( - 'Horde_Kolab_Server_Factory_Conn', $factory + 'Horde_Kolab_Server_Factory_Connection_Interface', $factory ); } @@ -125,7 +125,7 @@ implements Horde_Kolab_Server_Factory private function _setupObjects() { $this->_injector->bindImplementation( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', 'Horde_Kolab_Server_Objects_Base' ); } @@ -151,7 +151,7 @@ implements Horde_Kolab_Server_Factory private function _setupSchema() { $this->_injector->bindImplementation( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', 'Horde_Kolab_Server_Schema_Base' ); } @@ -183,8 +183,8 @@ implements Horde_Kolab_Server_Factory private function _setupConnection() { $this->_injector->bindFactory( - 'Horde_Kolab_Server_Connection', - 'Horde_Kolab_Server_Factory_Conn_Injector', + 'Horde_Kolab_Server_Connection_Interface', + 'Horde_Kolab_Server_Factory_Connection_Injector', 'getConnection' ); } @@ -197,7 +197,7 @@ implements Horde_Kolab_Server_Factory private function _setupServer() { $this->_injector->bindFactory( - 'Horde_Kolab_Server', + 'Horde_Kolab_Server_Interface', 'Horde_Kolab_Server_Factory_Injector', 'getServer' ); @@ -210,9 +210,10 @@ implements Horde_Kolab_Server_Factory */ private function _setupComposite() { - /** - * Nothing to do here for now as class and interface name are the same. - */ + $this->_injector->bindImplementation( + 'Horde_Kolab_Server_Composite_Interface', + 'Horde_Kolab_Server_Composite_Base' + ); } /** @@ -222,7 +223,9 @@ implements Horde_Kolab_Server_Factory */ public function getConnectionFactory() { - return $this->_injector->getInstance('Horde_Kolab_Server_Factory_Conn'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); } /** @@ -232,7 +235,9 @@ implements Horde_Kolab_Server_Factory */ public function getConnection() { - return $this->_injector->getInstance('Horde_Kolab_Server_Connection'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Connection_Interface' + ); } /** @@ -281,7 +286,9 @@ implements Horde_Kolab_Server_Factory */ public function getObjects() { - return $this->_injector->getInstance('Horde_Kolab_Server_Objects'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Objects_Interface' + ); } /** @@ -292,7 +299,9 @@ implements Horde_Kolab_Server_Factory */ public function getStructure() { - return $this->_injector->getInstance('Horde_Kolab_Server_Structure_Interface'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Structure_Interface' + ); } /** @@ -302,7 +311,9 @@ implements Horde_Kolab_Server_Factory */ public function getSearch() { - return $this->_injector->getInstance('Horde_Kolab_Server_Search_Interface'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Search_Interface' + ); } /** @@ -312,7 +323,9 @@ implements Horde_Kolab_Server_Factory */ public function getSchema() { - return $this->_injector->getInstance('Horde_Kolab_Server_Schema'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Schema_Interface' + ); } /** @@ -324,6 +337,8 @@ implements Horde_Kolab_Server_Factory */ public function getComposite() { - return $this->_injector->getInstance('Horde_Kolab_Server_Composite'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Composite_Interface' + ); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php similarity index 98% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php index ec2a8950f..9b2259a17 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Factory +interface Horde_Kolab_Server_Factory_Interface { /** * Returns a concrete Horde_Kolab_Server_Composite instance. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php similarity index 95% rename from framework/Kolab_Server/lib/Horde/Kolab/Server.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php index d80da8db1..0b06ce136 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server +interface Horde_Kolab_Server_Interface { /** * Connect to the server. @@ -126,7 +126,10 @@ interface Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data); + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ); /** * Add new object data. @@ -139,7 +142,10 @@ interface Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data); + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ); /** * Delete an object. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php index c40f9646f..1adfdd521 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php @@ -26,7 +26,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server +abstract class Horde_Kolab_Server_Ldap +implements Horde_Kolab_Server_Interface { /** * The GUID of the current user. @@ -58,7 +59,7 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * to all queries. */ public function __construct( - Horde_Kolab_Server_Connection $connection, + Horde_Kolab_Server_Connection_Interface $connection, $base_dn ) { $this->_conn = $connection; @@ -190,8 +191,10 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $changes = new Horde_Kolab_Server_Ldap_Changes($object, $data); $entry = $this->_conn->getWrite()->getEntry( $object->getGuid(), array_keys($data) @@ -214,8 +217,10 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $entry = Net_LDAP2_Entry::createFresh($object->getGuid(), $data); $this->_handleError($entry, Horde_Kolab_Server_Exception::SYSTEM); $this->_handleError( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php index 259977582..f9c38ef0c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php @@ -48,8 +48,10 @@ class Horde_Kolab_Server_Ldap_Changes * @param array $data The attributes of the object * to be stored. */ - public function __construct(Horde_Kolab_Server_Object $object, array $data) - { + public function __construct( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $this->_object = $object; $this->_data = $data; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php index e172f6f6b..54c897a1c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php @@ -44,7 +44,7 @@ class Horde_Kolab_Server_Ldap_Filtered extends Horde_Kolab_Server_Ldap * to all queries. */ public function __construct( - Horde_Kolab_Server_Connection $connection, + Horde_Kolab_Server_Connection_Interface $connection, $base_dn, $filter = null ) { diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php index cc740a34b..23f4238cd 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php @@ -41,6 +41,6 @@ class Horde_Kolab_Server_Ldap_Standard extends Horde_Kolab_Server_Ldap */ public function findBelow($query, $parent, array $params = array()) { - return $this->_search((string) $query, $params, $parent); + return $this->_search($query, $params, $parent); } } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/List.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/List/Interface.php similarity index 100% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/List.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/List/Interface.php diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php index c3e63b253..3ed439d9d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Object_Attribute_Base -implements Horde_Kolab_Server_Object_Attribute +implements Horde_Kolab_Server_Object_Attribute_Interface { /** * The attribute name on the internal side. @@ -65,15 +65,15 @@ implements Horde_Kolab_Server_Object_Attribute * @param string $name The name of this attribute. */ public function __construct( - Horde_Kolab_Server_Object $object, - Horde_Kolab_Server_Composite $composite, + Horde_Kolab_Server_Object_Interface $object, + Horde_Kolab_Server_Composite_Interface $composite, $external ) { $this->_object = $object; $this->_composite = $composite; $this->_external = $external; - $this->_internal = $this->_composite->structure->getInternalAttribute( + $this->_internal = $this->_composite->structure->mapExternalToInternalAttribute( $this->_external ); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php index 2142c5e37..5e7884930 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Attribute_Decorator -implements Horde_Kolab_Server_Object_Attribute +implements Horde_Kolab_Server_Object_Attribute_Interface { /** * The decorated attribute. @@ -42,7 +42,7 @@ implements Horde_Kolab_Server_Object_Attribute * attribute. */ public function __construct( - Horde_Kolab_Server_Object_Attribute $attribute + Horde_Kolab_Server_Object_Attribute_Interface $attribute ) { $this->_attribute = $attribute; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php similarity index 97% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php index 6d6b38ec5..5e3b8eb03 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Object_Attribute +interface Horde_Kolab_Server_Object_Attribute_Interface { /** * Return the value of this attribute. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php index eed3ebd29..aed9a9f3f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php @@ -36,8 +36,8 @@ extends Horde_Kolab_Server_Object_Attribute_Decorator * @param Horde_Kolab_Server_Composite $composite The link to the server. */ public function __construct( - Horde_Kolab_Server_Object $object, - Horde_Kolab_Server_Composite $composite + Horde_Kolab_Server_Object_Interface $object, + Horde_Kolab_Server_Composite_Interface $composite ) { $this->_attribute = new Horde_Kolab_Server_Object_Attribute_Required( new Horde_Kolab_Server_Object_Attribute_Locked( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php index 17e6d149a..cf89916c2 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php @@ -28,7 +28,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Object_Base -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface { /** * Link to the Kolab server. @@ -51,7 +51,7 @@ implements Horde_Kolab_Server_Object * @param string $guid GUID of the object. */ public function __construct( - Horde_Kolab_Server_Composite $composite, + Horde_Kolab_Server_Composite_Interface $composite, $guid = null ) { $this->_composite = $composite; diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php index 01150765e..da6ef99a0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php @@ -34,16 +34,17 @@ class Horde_Kolab_Server_Object_Factory * @param mixed $type The type of the Horde_Kolab_Server_Object subclass * to return. * @param string $uid UID of the object - * @param array &$storage A link to the Kolab_Server class handling read/write. + * @param array $storage A link to the Kolab_Server class handling read/write. * @param array $data A possible array of data for the object * * @return Horde_Kolab_Server_Object|PEAR_Error The newly created concrete * Horde_Kolab_Server_Object instance. */ - static public function &factory($type, $uid, &$storage, $data = null) - { - $result = Horde_Kolab_Server_Object::loadClass($type); - + static public function factory( + $type, $uid, + Horde_Kolab_Server_Composite $storage, + $data = null + ) { if (class_exists($type)) { $object = new $type($storage, $uid, $data); } else { @@ -53,6 +54,7 @@ class Horde_Kolab_Server_Object_Factory return $object; } + /** * Attempts to load the concrete Horde_Kolab_Server_Object class based on * $type. @@ -69,5 +71,4 @@ class Horde_Kolab_Server_Object_Factory throw new Horde_Kolab_Server_Exception('Class definition of ' . $type . ' not found.'); } } - } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php index 874979925..ac82299a4 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php @@ -27,6 +27,9 @@ */ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_Top { + /** The specific object class of this object type */ + const OBJECTCLASS_GROUPOFNAMES = 'groupOfNames'; + /** Define attributes specific to this object type */ /** The common name */ @@ -35,9 +38,6 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T /** The members of this group */ const ATTRIBUTE_MEMBER = 'member'; - /** The specific object class of this object type */ - const OBJECTCLASS_GROUPOFNAMES = 'groupOfNames'; - /** * A structure to initialize the attribute structure for this class. * @@ -159,71 +159,4 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T return true; } } - - /** - * Returns the set of search operations supported by this object type. - * - * @return array An array of supported search operations. - */ - static public function getSearchOperations() - { - $searches = array( -/* 'gidForSearch', */ -/* 'getGroups', */ - ); - return $searches; - } - - /** - * @todo: This method belongs somewhere where we are aware of groups - * Identify the GID for the first group found using the specified - * search criteria - * - * @param array $criteria The search parameters as array. - * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction. - * - * @return boolean|string|array The GID(s) or false if there was no result. - * - * @throws Horde_Kolab_Server_Exception - */ - static public function gidForSearch($server, $criteria, - $restrict = 0) - { - $groups = array('field' => self::ATTRIBUTE_OC, - 'op' => '=', - 'test' => self::OBJECTCLASS_GROUPOFNAMES); - if (!empty($criteria)) { - $criteria = array('AND' => array($groups, $criteria)); - } else { - $criteria = array('AND' => array($groups)); - } - return self::basicUidForSearch($server, $criteria, $restrict); - } - - /** - * Get the groups for this object. - * - * @param string $uid The UID of the object to fetch. - * - * @return array An array of group ids. - * - * @throws Horde_Kolab_Server_Exception - */ - static public function getGroups($server, $uid) - { - $criteria = array('AND' => - array( - array('field' => self::ATTRIBUTE_MEMBER, - 'op' => '=', - 'test' => $uid), - ), - ); - - $result = self::gidForSearch($server, $criteria, self::RESULT_MANY); - if (empty($result)) { - return array(); - } - return $result; - } - } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php index c5e38f96a..c8486b9a3 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Hash -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface //@todo: Implement ArrayAccess { /** diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php index 408f995b6..8255c5fb1 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php @@ -88,105 +88,105 @@ class Horde_Kolab_Server_Object_Inetorgperson extends Horde_Kolab_Server_Object_ * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_SID, - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_MAIL, - self::ATTRIBUTE_LABELEDURI, - self::ATTRIBUTE_HOMEPOSTALADDRESS, - self::ATTRIBUTE_ORGANIZATION, - self::ATTRIBUTE_BUSINESSCATEGORY, - self::ATTRIBUTE_HOMEPHONE, - self::ATTRIBUTE_MOBILE, - self::ATTRIBUTE_PHOTO, - self::ATTRIBUTE_JPEGPHOTO, - self::ATTRIBUTE_SMIMECERTIFICATE, - ), - 'derived' => array( - self::ATTRARRAY_HOMEPOSTALADDRESS => array( - 'base' => array( - self::ATTRIBUTE_HOMEPOSTALADDRESS, - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getHomePostalAddressHash', - ), - self::ATTRARRAY_LABELEDURI => array( - 'base' => array( - self::ATTRIBUTE_LABELEDURI, - ), - 'method' => 'getLabeledUriHash', - ), - self::ATTRIBUTE_GIVENNAME => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - ), - 'method' => 'getField', - 'args' => array( - self::ATTRIBUTE_GIVENNAME, - 0, - ' ' - ), - ), - self::ATTRIBUTE_MIDDLENAMES => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - ), - 'method' => 'getField', - 'args' => array( - self::ATTRIBUTE_GIVENNAME, - 1, - ' ', - 2 - ), - ), - self::ATTRIBUTE_FNLN => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getFnLn', - ), - self::ATTRIBUTE_LNFN => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getLnFn', - ), - ), - 'collapsed' => array( - self::ATTRIBUTE_GIVENNAME => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_MIDDLENAMES, - ), - 'method' => 'setField', - 'args' => array( - ' ', - ), - ), - self::ATTRIBUTE_LABELEDURI => array( - 'base' => array( - self::ATTRARRAY_LABELEDURI, - ), - 'method' => 'setLabeledUriHash', - ), - self::ATTRIBUTE_HOMEPOSTALADDRESS => array( - 'base' => array( - self::ATTRARRAY_HOMEPOSTALADDRESS, - ), - 'method' => 'setHomePostalAddressHash', - ), - ), - 'locked' => array( - self::ATTRIBUTE_MAIL, - ), - 'object_classes' => array( - self::OBJECTCLASS_INETORGPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_SID, */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_MAIL, */ +/* self::ATTRIBUTE_LABELEDURI, */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS, */ +/* self::ATTRIBUTE_ORGANIZATION, */ +/* self::ATTRIBUTE_BUSINESSCATEGORY, */ +/* self::ATTRIBUTE_HOMEPHONE, */ +/* self::ATTRIBUTE_MOBILE, */ +/* self::ATTRIBUTE_PHOTO, */ +/* self::ATTRIBUTE_JPEGPHOTO, */ +/* self::ATTRIBUTE_SMIMECERTIFICATE, */ +/* ), */ +/* 'derived' => array( */ +/* self::ATTRARRAY_HOMEPOSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS, */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getHomePostalAddressHash', */ +/* ), */ +/* self::ATTRARRAY_LABELEDURI => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_LABELEDURI, */ +/* ), */ +/* 'method' => 'getLabeledUriHash', */ +/* ), */ +/* self::ATTRIBUTE_GIVENNAME => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* ), */ +/* 'method' => 'getField', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* 0, */ +/* ' ' */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_MIDDLENAMES => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* ), */ +/* 'method' => 'getField', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* 1, */ +/* ' ', */ +/* 2 */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_FNLN => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getFnLn', */ +/* ), */ +/* self::ATTRIBUTE_LNFN => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getLnFn', */ +/* ), */ +/* ), */ +/* 'collapsed' => array( */ +/* self::ATTRIBUTE_GIVENNAME => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_MIDDLENAMES, */ +/* ), */ +/* 'method' => 'setField', */ +/* 'args' => array( */ +/* ' ', */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_LABELEDURI => array( */ +/* 'base' => array( */ +/* self::ATTRARRAY_LABELEDURI, */ +/* ), */ +/* 'method' => 'setLabeledUriHash', */ +/* ), */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRARRAY_HOMEPOSTALADDRESS, */ +/* ), */ +/* 'method' => 'setHomePostalAddressHash', */ +/* ), */ +/* ), */ +/* 'locked' => array( */ +/* self::ATTRIBUTE_MAIL, */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_INETORGPERSON, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php similarity index 98% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php index bd13a29e1..c82fc53bf 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Object +interface Horde_Kolab_Server_Object_Interface { /** * Get the GUID of this object diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php index 344afdaa6..d962f8390 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php @@ -48,15 +48,15 @@ class Horde_Kolab_Server_Object_Kolab_User extends Horde_Kolab_Server_Object_Kol * * @var array */ - static public $init_attributes = array( - 'derived' => array( - self::ATTRIBUTE_USERTYPE => array(), - self::ATTRIBUTE_FN => array(), - ), - 'required' => array( - self::ATTRIBUTE_USERPASSWORD, - ), - ); +/* static public $init_attributes = array( */ +/* 'derived' => array( */ +/* self::ATTRIBUTE_USERTYPE => array(), */ +/* self::ATTRIBUTE_FN => array(), */ +/* ), */ +/* 'required' => array( */ +/* self::ATTRIBUTE_USERPASSWORD, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php index 9f4e85017..9a4c3a1f0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php @@ -59,66 +59,66 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_ALIAS, - self::ATTRIBUTE_DELEGATE, - self::ATTRIBUTE_DELETED, - self::ATTRIBUTE_FBFUTURE, - self::ATTRIBUTE_HOMESERVER, - self::ATTRIBUTE_FREEBUSYHOST, - self::ATTRIBUTE_IMAPHOST, - self::ATTRIBUTE_IPOLICY, - self::ATTRIBUTE_SALUTATION, - self::ATTRIBUTE_GENDER, - self::ATTRIBUTE_MARITALSTATUS, - self::ATTRIBUTE_HOMEFAX, - self::ATTRIBUTE_GERMANTAXID, - self::ATTRIBUTE_COUNTRY, - self::ATTRIBUTE_QUOTA, - self::ATTRIBUTE_ALLOWEDRECIPIENTS, - self::ATTRIBUTE_ALLOWEDFROM, - self::ATTRIBUTE_DATEOFBIRTH, - self::ATTRIBUTE_PLACEOFBIRTH, - self::ATTRIBUTE_BIRTHNAME, - self::ATTRIBUTE_PSEUDONYM, - self::ATTRIBUTE_COUNTRYCITIZENSHIP, - self::ATTRIBUTE_LEGALFORM, - self::ATTRIBUTE_REGISTEREDCAPITAL, - self::ATTRIBUTE_BYLAWURI, - self::ATTRIBUTE_DATEOFINCORPORATION, - self::ATTRIBUTE_LEGALREPRESENTATIVE, - self::ATTRIBUTE_COMMERCIALPROCURATION, - self::ATTRIBUTE_LEGALREPRESENTATIONPOLICY, - self::ATTRIBUTE_ACTINGDEPUTY, - self::ATTRIBUTE_VATNUMBER, - self::ATTRIBUTE_OTHERLEGAL, - self::ATTRIBUTE_INLIQUIDATION, - self::ATTRIBUTE_TRTYPE, - self::ATTRIBUTE_TRLOCATION, - self::ATTRIBUTE_TRIDENTIFIER, - self::ATTRIBUTE_TRURI, - self::ATTRIBUTE_TRLASTCHANGED, - self::ATTRIBUTE_DC, - ), - 'locked' => array( - self::ATTRIBUTE_MAIL, - ), - /** - * Derived attributes are calculated based on other attribute values. - */ - 'derived' => array( - self::ATTRDATE_DATEOFBIRTH => array( - 'method' => 'getDate', - 'args' => array( - self::ATTRIBUTE_DATEOFBIRTH, - ), - ), - ), - 'object_classes' => array( - self::OBJECTCLASS_KOLABINETORGPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_ALIAS, */ +/* self::ATTRIBUTE_DELEGATE, */ +/* self::ATTRIBUTE_DELETED, */ +/* self::ATTRIBUTE_FBFUTURE, */ +/* self::ATTRIBUTE_HOMESERVER, */ +/* self::ATTRIBUTE_FREEBUSYHOST, */ +/* self::ATTRIBUTE_IMAPHOST, */ +/* self::ATTRIBUTE_IPOLICY, */ +/* self::ATTRIBUTE_SALUTATION, */ +/* self::ATTRIBUTE_GENDER, */ +/* self::ATTRIBUTE_MARITALSTATUS, */ +/* self::ATTRIBUTE_HOMEFAX, */ +/* self::ATTRIBUTE_GERMANTAXID, */ +/* self::ATTRIBUTE_COUNTRY, */ +/* self::ATTRIBUTE_QUOTA, */ +/* self::ATTRIBUTE_ALLOWEDRECIPIENTS, */ +/* self::ATTRIBUTE_ALLOWEDFROM, */ +/* self::ATTRIBUTE_DATEOFBIRTH, */ +/* self::ATTRIBUTE_PLACEOFBIRTH, */ +/* self::ATTRIBUTE_BIRTHNAME, */ +/* self::ATTRIBUTE_PSEUDONYM, */ +/* self::ATTRIBUTE_COUNTRYCITIZENSHIP, */ +/* self::ATTRIBUTE_LEGALFORM, */ +/* self::ATTRIBUTE_REGISTEREDCAPITAL, */ +/* self::ATTRIBUTE_BYLAWURI, */ +/* self::ATTRIBUTE_DATEOFINCORPORATION, */ +/* self::ATTRIBUTE_LEGALREPRESENTATIVE, */ +/* self::ATTRIBUTE_COMMERCIALPROCURATION, */ +/* self::ATTRIBUTE_LEGALREPRESENTATIONPOLICY, */ +/* self::ATTRIBUTE_ACTINGDEPUTY, */ +/* self::ATTRIBUTE_VATNUMBER, */ +/* self::ATTRIBUTE_OTHERLEGAL, */ +/* self::ATTRIBUTE_INLIQUIDATION, */ +/* self::ATTRIBUTE_TRTYPE, */ +/* self::ATTRIBUTE_TRLOCATION, */ +/* self::ATTRIBUTE_TRIDENTIFIER, */ +/* self::ATTRIBUTE_TRURI, */ +/* self::ATTRIBUTE_TRLASTCHANGED, */ +/* self::ATTRIBUTE_DC, */ +/* ), */ +/* 'locked' => array( */ +/* self::ATTRIBUTE_MAIL, */ +/* ), */ +/* /\** */ +/* * Derived attributes are calculated based on other attribute values. */ +/* *\/ */ +/* 'derived' => array( */ +/* self::ATTRDATE_DATEOFBIRTH => array( */ +/* 'method' => 'getDate', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_DATEOFBIRTH, */ +/* ), */ +/* ), */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_KOLABINETORGPERSON, */ +/* ), */ +/* ); */ /** * Generates an ID for the given information. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php index ae57cfcf0..74eeaba06 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Mcached -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface { /** * Link to the decorated object. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php index 9f864a844..584507696 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php @@ -58,32 +58,32 @@ class Horde_Kolab_Server_Object_Organizationalperson extends Horde_Kolab_Server_ * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_JOBTITLE, - self::ATTRIBUTE_STREET, - self::ATTRIBUTE_POSTOFFICEBOX, - self::ATTRIBUTE_POSTALCODE, - self::ATTRIBUTE_CITY, - self::ATTRIBUTE_FAX, - self::ATTRIBUTE_POSTALADDRESS, - ), - 'collapsed' => array( - self::ATTRIBUTE_POSTALADDRESS => array( - 'base' => array( - self::ATTRIBUTE_SN, - self::ATTRIBUTE_STREET, - self::ATTRIBUTE_POSTOFFICEBOX, - self::ATTRIBUTE_POSTALCODE, - self::ATTRIBUTE_CITY, - ), - 'method' => 'setPostalAddress', - ), - ), - 'object_classes' => array( - self::OBJECTCLASS_ORGANIZATIONALPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_JOBTITLE, */ +/* self::ATTRIBUTE_STREET, */ +/* self::ATTRIBUTE_POSTOFFICEBOX, */ +/* self::ATTRIBUTE_POSTALCODE, */ +/* self::ATTRIBUTE_CITY, */ +/* self::ATTRIBUTE_FAX, */ +/* self::ATTRIBUTE_POSTALADDRESS, */ +/* ), */ +/* 'collapsed' => array( */ +/* self::ATTRIBUTE_POSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_SN, */ +/* self::ATTRIBUTE_STREET, */ +/* self::ATTRIBUTE_POSTOFFICEBOX, */ +/* self::ATTRIBUTE_POSTALCODE, */ +/* self::ATTRIBUTE_CITY, */ +/* ), */ +/* 'method' => 'setPostalAddress', */ +/* ), */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_ORGANIZATIONALPERSON, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php index 1c38fbdab..6d58d60c0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php @@ -26,7 +26,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects +class Horde_Kolab_Server_Objects_Base +implements Horde_Kolab_Server_Objects_Interface { /** * A link to the composite server handler. @@ -43,8 +44,9 @@ class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite) - { + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ) { $this->_composite = $composite; } @@ -85,8 +87,8 @@ class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects $type = $this->_composite->structure->determineType($guid); } - $object = &Horde_Kolab_Server_Object_Factory::factory( - $type, $guid, $this->_composite->server + $object = Horde_Kolab_Server_Object_Factory::factory( + $type, $guid, $this->_composite ); return $object; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php similarity index 96% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php index 5b941e5cd..7e1e2a4f0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Objects +interface Horde_Kolab_Server_Objects_Interface { /** * Set the composite server reference for this object. @@ -33,7 +33,9 @@ interface Horde_Kolab_Server_Objects * @param Horde_Kolab_Server_Composite $composite A link to the composite * server handler. */ - public function setComposite(Horde_Kolab_Server_Composite $composite); + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); /** * Add a Kolab object. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php index abe52bacd..a6621ea8d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertAnd($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php index 486ce564c..de5222791 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertApprox($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php index 3686bc373..2d330362f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertBegins($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php index 224d187f6..480e1b8c8 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertContains($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php index 742f9ba68..035b58991 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertEnds($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php index c8164ae67..2f24224fc 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertEquals($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php index a7f843cbd..9ca000187 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertGreater($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php index d861d1a61..9038af0af 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Query_Element_Group -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * The group elements. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php similarity index 90% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php index 3071c6a96..0c4a256b0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Query_Element +interface Horde_Kolab_Server_Query_Element_Interface { /** * Return the query element name. @@ -53,6 +53,7 @@ interface Horde_Kolab_Server_Query_Element * * @return mixedd The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer); - + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ); } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php index 00df41fb2..6c37b0567 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertLess($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php index 2cd6123f8..fb01c87f6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Query_Element_Mapped -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * Delegated element. @@ -49,8 +49,8 @@ implements Horde_Kolab_Server_Query_Element * @param Horde_Kolab_Server_Mapped $mapper The mapping handler. */ public function __construct( - Horde_Kolab_Server_Query_Element $element, - Horde_Kolab_Server_Mapped $mapper + Horde_Kolab_Server_Query_Element_Interface $element, + Horde_Kolab_Server_Decorator_Map $mapper ) { $this->_element = $element; $this->_mapper = $mapper; @@ -97,8 +97,9 @@ implements Horde_Kolab_Server_Query_Element * * @return string The query string of the element. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $this->_element->convert($writer); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php index 2f7340de5..e5e74926e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php @@ -33,7 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @param array $elements The group elements. */ - public function __construct(Horde_Kolab_Server_Query_Element $element) { + public function __construct( + Horde_Kolab_Server_Query_Element_Interface $element + ) { parent::__construct(array($element)); } @@ -42,8 +44,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertNot($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php index 6e89b2892..38797551b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertOr($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php index 59b6cc576..ea9067583 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Query_Element_Single -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * The element name. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php similarity index 98% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php index 706e2ebd1..b1e65e314 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Query +interface Horde_Kolab_Server_Query_Interface { /** * Return the query as a string. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php index ae24422ad..51815c37c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query +class Horde_Kolab_Server_Query_Ldap +implements Horde_Kolab_Server_Query_Interface { /** * The query criteria. @@ -47,7 +48,7 @@ class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query * @param array $criteria The query criteria. */ public function __construct( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, Horde_Kolab_Server_Structure_Interface $structure ) { $this->_criteria = $criteria; @@ -185,7 +186,9 @@ class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query $operator ) { $result = Net_LDAP2_Filter::create( - $this->_structure->getInternalAttribute($single->getName()), + $this->_structure->mapExternalToInternalAttribute( + $single->getName() + ), $operator, $single->getValue() ); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php similarity index 96% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php index bf365fdce..cfb28b88a 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php @@ -25,7 +25,7 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -interface Horde_Kolab_Server_Result +interface Horde_Kolab_Server_Result_Interface { /** * The number of result entries. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php index 7494569bd..ecab1351b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Result_Ldap implements Horde_Kolab_Server_Result +class Horde_Kolab_Server_Result_Ldap +implements Horde_Kolab_Server_Result_Interface { /** * The search result. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php index 4193e93c9..5ac063d80 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php @@ -1,6 +1,6 @@ composite = $composite; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php new file mode 100644 index 000000000..ef2bfc6b7 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php @@ -0,0 +1,280 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * This class handles the db schema. + * + * Copyright 2008-2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Schema_Base +implements Horde_Kolab_Server_Schema_Interface +{ + /** Maximum accepted level for the object class hierarchy */ + const MAX_HIERARCHY = 100; + + /** + * A cache for object attribute definitions. + * + * @var array + */ + protected $attributes; + + /** + * A link to the composite server handler. + * + * @var Horde_Kolab_Server_Composite + */ + protected $composite; + + /** + * Set the composite server reference for this object. + * + * @param Horde_Kolab_Server_Composite $composite A link to the composite + * server handler. + * + * @return NULL + */ + public function setComposite(Horde_Kolab_Server_Composite $composite) + { + $this->composite = $composite; + } + + /** + * Return the schema for the given objectClass. + * + * @param string $objectclass Fetch the schema for this objectClass. + * + * @return array The schema for the given objectClass. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getObjectclassSchema($objectclass) + { + if (!empty($this->_config['schema_support'])) { + $schema = $this->_getSchema(); + $info = $schema->get('objectclass', $objectclass); + $this->_handleError($info, Horde_Kolab_Server_Exception::SYSTEM); + return $info; + } + return parent::getObjectclassSchema($objectclass); + } + + /** + * Return the schema for the given attribute. + * + * @param string $attribute Fetch the schema for this attribute. + * + * @return array The schema for the given attribute. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getAttributeSchema($attribute) + { + if (!empty($this->_config['schema_support'])) { + $schema = $this->_getSchema(); + $info = $schema->get('attribute', $attribute); + $this->_handleError($info, Horde_Kolab_Server_Exception::SYSTEM); + return $info; + } + return parent::getAttributeSchema($attribute); + } + + /** + * Return the attributes supported by the given object class. + * + * @param string $class Determine the attributes for this class. + * + * @return array The supported attributes. + * + * @throws Horde_Kolab_Server_Exception If the schema analysis fails. + */ + public function getExternalAttributes($class) + { + if (!isset($this->attributes)) { + if (isset($this->cache)) { + register_shutdown_function(array($this, 'shutdown')); + } + } + if (empty($this->attributes[$class])) { + + if (isset($this->cache)) { + $this->attributes[$class] = @unserialize($cache->get('attributes_' . $class, + $this->params['cache_lifetime'])); + } + + if (empty($this->attributes[$class])) { + + $childclass = $class; + $classes = array(); + $level = 0; + while ($childclass != 'Horde_Kolab_Server_Object' + && $level < self::MAX_HIERARCHY) { + $classes[] = $childclass; + $childclass = get_parent_class($childclass); + $level++; + } + + /** Finally add the basic object class */ + $classes[] = $childclass; + + if ($level == self::MAX_HIERARCHY) { + if (isset($this->logger)) { + $logger->err(sprintf('The maximal level of the object hierarchy has been exceeded for class \"%s\"!', + $class)); + } + } + + /** + * Collect attributes from bottom to top. + */ + $classes = array_reverse($classes); + + $types = array('defined', 'required', 'derived', 'collapsed', + 'defaults', 'locked', 'object_classes'); + foreach ($types as $type) { + $$type = array(); + } + + foreach ($classes as $childclass) { + $vars = get_class_vars($childclass); + if (isset($vars['init_attributes'])) { + foreach ($types as $type) { + /** + * If the user wishes to adhere to the schema + * information from the server we will skip the + * attributes defined within the object class here. + */ + if (!empty($this->params['schema_override']) + && in_array($type, 'defined', 'required')) { + continue; + } + if (isset($vars['init_attributes'][$type])) { + $$type = array_merge($$type, + $vars['init_attributes'][$type]); + } + } + } + } + + $attrs = array(); + + foreach ($object_classes as $object_class) { + $info = $this->getObjectclassSchema($object_class); + if (isset($info['may'])) { + $defined = array_merge($defined, $info['may']); + } + if (isset($info['must'])) { + $defined = array_merge($defined, $info['must']); + $required = array_merge($required, $info['must']); + } + foreach ($defined as $attribute) { + try { + $attrs[$attribute] = $this->getAttributeSchema($attribute); + } catch (Horde_Kolab_Server_Exception $e) { + /** + * If the server considers the attribute to be + * invalid we mark it. + */ + $attrs[$attribute] = array('invalid' => true); + } + } + foreach ($required as $attribute) { + $attrs[$attribute]['required'] = true; + } + foreach ($locked as $attribute) { + $attrs[$attribute]['locked'] = true; + } + foreach ($defaults as $attribute => $default) { + $attrs[$attribute]['default'] = $default; + } + $attrs[Horde_Kolab_Server_Object::ATTRIBUTE_OC]['default'] = $object_classes; + } + foreach ($derived as $key => $attributes) { + $supported = true; + if (isset($attributes['base'])) { + foreach ($attributes['base'] as $attribute) { + /** + * Usually derived attribute are determined on basis + * of one or more attributes. If any of these is not + * supported the derived attribute should not be + * included into the set of supported attributes. + */ + if (!isset($attrs[$attribute])) { + unset($derived[$attribute]); + $supported = false; + break; + } + } + } + if ($supported) { + $attrs[$key] = $attributes; + } + } + $check_collapsed = $collapsed; + foreach ($check_collapsed as $key => $attributes) { + if (isset($attributes['base'])) { + foreach ($attributes['base'] as $attribute) { + /** + * Usually collapsed attribute are determined on basis + * of one or more attributes. If any of these is not + * supported the collapsed attribute should not be + * included into the set of supported attributes. + */ + if (!isset($attrs[$attribute])) { + unset($collapsed[$attribute]); + } + } + } + } + $this->attributes[$class] = array($attrs, + array( + 'derived' => array_keys($derived), + 'collapsed' => $collapsed, + 'locked' => $locked, + 'required' => $required)); + } + } + return $this->attributes[$class]; + } + + public function getInternalAttributes($class) + { + } + + /** + * Stores the attribute definitions in the cache. + * + * @return Horde_Kolab_Server The concrete Horde_Kolab_Server reference. + */ + public function shutdown() + { + if (isset($this->attributes)) { + if (isset($this->cache)) { + foreach ($this->attributes as $key => $value) { + $this->cache->set('attributes_' . $key, @serialize($value)); + } + } + } + } + + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php similarity index 90% rename from framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php rename to framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php index 0d2dda9d0..23b26a78f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php @@ -1,6 +1,6 @@ _composite = $composite; $this->_searches = $this->_getSearchOperations(); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php index 740b49462..281c0ef7e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php @@ -33,7 +33,9 @@ interface Horde_Kolab_Server_Search_Interface * @param Horde_Kolab_Server_Composite $composite A link to the composite * server handler. */ - public function setComposite(Horde_Kolab_Server_Composite $composite); + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); /** * Returns the set of search operations supported by this server type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php index 17df4fbb7..7f4b44fe0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php @@ -65,8 +65,9 @@ implements Horde_Kolab_Server_Search_Operation_Interface * * @return boolean|array The GUID(s) or false if there was no result. */ - protected function guidFromResult(Horde_Kolab_Server_Result $result) - { + protected function guidFromResult( + Horde_Kolab_Server_Result_Interface $result + ) { return array_keys($result->asArray()); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php new file mode 100644 index 000000000..ff27eefc4 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php @@ -0,0 +1,47 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Return the groups for the given member element. + * + * Copyright 2008-2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Search_Operation_Groupsformember +extends Horde_Kolab_Server_Search_Operation_Restrictgroups +{ + /** + * Return the groups for the given member element. + * + * @param string $guid The guid of the member. + * + * @return array The group GUID(s). + * + * @throws Horde_Kolab_Server_Exception + */ + public function searchGroupsForMember($guid) + { + $criteria = new Horde_Kolab_Server_Query_Element_Equals( + 'member', $guid + ); + return parent::searchRestrictGroups($criteria); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php index d0049bc0c..ffc646694 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php @@ -35,8 +35,9 @@ extends Horde_Kolab_Server_Search_Operation_Base * * @return array The search result. */ - public function searchGuid(Horde_Kolab_Server_Query_Element $criteria) - { + public function searchGuid( + Horde_Kolab_Server_Query_Element_Interface $criteria + ) { $params = array( 'attributes' => 'Guid' ); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php new file mode 100644 index 000000000..942727aad --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php @@ -0,0 +1,54 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Restrict a search to groupOfNames. + * + * Copyright 2008-2009 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_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Search_Operation_Restrictgroups +extends Horde_Kolab_Server_Search_Operation_Guid +{ + /** + * Restrict a search to groupOfNames. + * + * @param Horde_Kolab_Server_Query_Element $criteria The search criteria. + * + * @return array The GUID(s). + * + * @throws Horde_Kolab_Server_Exception + */ + public function searchRestrictGroups( + Horde_Kolab_Server_Query_Element $criteria + ) { + $criteria = new Horde_Kolab_Server_Query_Element_And( + array( + new Horde_Kolab_Server_Query_Element_Equals( + 'Objectclass', + Horde_Kolab_Server_Object_Groupofnames::OBJECTCLASS_GROUPOFNAMES + ), + $criteria + ) + ); + return parent::searchGuid($criteria); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php index a851db8ec..565b4a6a6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php @@ -46,7 +46,7 @@ implements Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function find( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, array $params = array() ) { $query = new Horde_Kolab_Server_Query_Ldap($criteria, $this); @@ -67,7 +67,7 @@ implements Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function findBelow( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, $parent, array $params = array() ) { @@ -85,8 +85,9 @@ implements Horde_Kolab_Server_Structure_Interface * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite) - { + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ) { $this->_composite = $composite; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php index 01f2d12e9..a6a2ebc11 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php @@ -39,7 +39,7 @@ interface Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function find( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, array $params = array() ); @@ -55,7 +55,7 @@ interface Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function findBelow( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, $parent, array $params = array() ); @@ -68,7 +68,9 @@ interface Horde_Kolab_Server_Structure_Interface * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite); + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); /** * Returns the set of objects supported by this structure. @@ -91,7 +93,7 @@ interface Horde_Kolab_Server_Structure_Interface * * @return string The internal attribute name. */ - public function getInternalAttribute($external); + public function mapExternalToInternalAttribute($external); /** * Determine the type of an object by its tree position and other diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php index 819a9b970..e763b354d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php @@ -77,6 +77,7 @@ class Horde_Kolab_Server_Structure_Kolab extends Horde_Kolab_Server_Structure_Ld 'Horde_Kolab_Server_Search_Operation_Guidforuidormailoralias', 'Horde_Kolab_Server_Search_Operation_Mailforuidormail', 'Horde_Kolab_Server_Search_Operation_Addressesforuidormail', + 'Horde_Kolab_Server_Search_Operation_Groupsformember', ); return $searches; } @@ -111,7 +112,7 @@ class Horde_Kolab_Server_Structure_Kolab extends Horde_Kolab_Server_Structure_Ld return parent::_determineType($guid, $ocs); } - $groups = $this->getComposite()->search->getGroups($guid); + $groups = $this->getComposite()->search->searchGroupsForMember($guid); if (!empty($groups)) { $base = $this->getComposite()->server->getBaseGuid(); if (in_array('cn=admin,cn=internal,' . $base, $groups)) { diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php index 64f0f028d..bf047c2a6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php @@ -154,7 +154,7 @@ class Horde_Kolab_Server_Structure_Ldap extends Horde_Kolab_Server_Structure_Bas * * @return string The internal attribute name. */ - public function getInternalAttribute($external) + public function mapExternalToInternalAttribute($external) { switch ($external) { case 'Objectclass': diff --git a/framework/Kolab_Server/package.xml b/framework/Kolab_Server/package.xml index 898267f92..89d8a1084 100644 --- a/framework/Kolab_Server/package.xml +++ b/framework/Kolab_Server/package.xml @@ -59,13 +59,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + + @@ -74,41 +75,47 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + + + - - - - + + - + + + + + + + + - - + - - - - @@ -118,6 +125,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -132,6 +140,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -152,13 +161,11 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + - - @@ -168,21 +175,23 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + - + - + @@ -196,6 +205,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -207,6 +217,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -236,12 +247,12 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + - + @@ -332,42 +343,43 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + + + + - - - - - - - - + + + + + + + + + + + - - + - - - - @@ -375,6 +387,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -389,6 +402,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -406,10 +420,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - + @@ -418,16 +430,18 @@ http://pear.php.net/dtd/package-2.0.xsd"> + - + - + + @@ -436,6 +450,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -447,6 +462,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -461,10 +477,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php similarity index 81% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php index dcdabf534..74a6088ff 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../TestCase.php'; +require_once dirname(__FILE__) . '/../../../TestCase.php'; /** * Test the composite server. @@ -30,16 +30,16 @@ require_once dirname(__FILE__) . '/../../TestCase.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_CompositeTest extends Horde_Kolab_Server_TestCase +class Horde_Kolab_Server_Class_Server_Composite_BaseTest extends Horde_Kolab_Server_TestCase { public function testMethodGetReturnsServerElement() { $composite = $this->getMockedComposite(); - $this->assertType('Horde_Kolab_Server', $composite->server); - $this->assertType('Horde_Kolab_Server_Objects', $composite->objects); + $this->assertType('Horde_Kolab_Server_Interface', $composite->server); + $this->assertType('Horde_Kolab_Server_Objects_Interface', $composite->objects); $this->assertType('Horde_Kolab_Server_Structure_Interface', $composite->structure); $this->assertType('Horde_Kolab_Server_Search_Interface', $composite->search); - $this->assertType('Horde_Kolab_Server_Schema', $composite->schema); + $this->assertType('Horde_Kolab_Server_Schema_Interface', $composite->schema); try { $a = $composite->something; $this->fail('No exception!'); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php similarity index 88% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php index cf72621d2..0b61e09f2 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../Autoload.php'; +require_once dirname(__FILE__) . '/../../../Autoload.php'; /** * Test the cleanup decorator for the server. @@ -30,14 +30,14 @@ require_once dirname(__FILE__) . '/../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_TestCase +class Horde_Kolab_Server_Class_Server_Decorator_CleanTest extends PHPUnit_Framework_TestCase { public function setUp() { parent::setUp(); - $this->server = $this->getMock('Horde_Kolab_Server'); - $this->cleaner = new Horde_Kolab_Server_Cleaner($this->server); + $this->server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->cleaner = new Horde_Kolab_Server_Decorator_Clean($this->server); } public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer() @@ -102,7 +102,7 @@ class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_Test public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer() { - $result = $this->getMock('Horde_Kolab_Server_Result'); + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); $query = $this->getMock( 'Horde_Kolab_Server_Query_Element', array(), array(), '', false ); @@ -111,16 +111,14 @@ class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_Test ->with($query, 'none') ->will($this->returnValue($result)); $this->assertType( - 'Horde_Kolab_Server_Result', + 'Horde_Kolab_Server_Result_Interface', $this->cleaner->findBelow($query, 'none') ); } public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->server->expects($this->exactly(1)) ->method('save') ->with($object, array('a' => 'a')); @@ -129,9 +127,7 @@ class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_Test public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->server->expects($this->exactly(1)) ->method('add') ->with($object, array('a' => 'a')); @@ -171,9 +167,7 @@ class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_Test public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsRememberedAndDeletedOnDestruction() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->exactly(1)) ->method('getGuid') ->will($this->returnValue('a')); @@ -189,9 +183,7 @@ class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_Test public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsNotDeletedOnDestructionIfItWasDeletedBefore() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->exactly(1)) ->method('getGuid') ->will($this->returnValue('a')); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php similarity index 90% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php index f094ee9cc..b03e4e767 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../Autoload.php'; +require_once dirname(__FILE__) . '/../../../Autoload.php'; /** * Test the log decorator for the server. @@ -30,15 +30,15 @@ require_once dirname(__FILE__) . '/../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestCase +class Horde_Kolab_Server_Class_Server_Decorator_LogTest extends PHPUnit_Framework_TestCase { public function setUp() { parent::setUp(); $this->logger = $this->getMock('Horde_Log_Logger'); - $this->server = $this->getMock('Horde_Kolab_Server'); - $this->logged = new Horde_Kolab_Server_Logged( + $this->server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->logged = new Horde_Kolab_Server_Decorator_Log( $this->server, $this->logger ); } @@ -121,9 +121,7 @@ class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestC public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->server->expects($this->exactly(1)) ->method('save') ->with($object, array('a' => 'a')); @@ -132,9 +130,7 @@ class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestC public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->server->expects($this->exactly(1)) ->method('add') ->with($object, array('a' => 'a')); @@ -166,9 +162,7 @@ class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestC public function testMethodSaveHasPostconditionThatTheEventWasLogged() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('getGuid') ->will($this->returnValue('a')); @@ -182,9 +176,7 @@ class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestC public function testMethodAddHasPostconditionThatTheEventWasLogged() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('getGuid') ->will($this->returnValue('a')); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php index 5939ce322..4eec53d00 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php @@ -39,7 +39,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('logger' => 'set', 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Log', $factory->getServer() + ); } public function testMethodGetserverHasResultMappedServerIfAMappedWasProvidedInTheConfiguration() @@ -48,7 +50,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('map' => array(), 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Map', $factory->getServer() + ); } public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() @@ -57,7 +61,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('cleanup' => true, 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Clean', $factory->getServer() + ); } public function testMethodConstructHasParametersArrayParameters() @@ -73,7 +79,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Factory_Conn', + 'Horde_Kolab_Server_Factory_Connection_Interface', $factory->getConnectionFactory() ); } @@ -85,7 +91,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server', + 'Horde_Kolab_Server_Interface', $factory->getServer() ); } @@ -108,7 +114,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -120,7 +126,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } @@ -131,7 +137,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', $factory->getObjects() ); } @@ -164,7 +170,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', $factory->getSchema() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php similarity index 82% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php index 746c67381..c3f529567 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php @@ -30,19 +30,19 @@ require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_ConfigurationTest +class Horde_Kolab_Server_Class_Server_Factory_Connection_ConfigurationTest extends Horde_Kolab_Server_LdapTestCase { public function testMethodConstructHasParameterArrayConfiguration() { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( array('basedn' => 'a') ); } public function testMethodConstructHasPostconditionThatTheConfigurationWasSaved() { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( array('basedn' => 'a') ); $this->assertEquals(array('basedn' => 'a'), $factory->getConfiguration()); @@ -50,7 +50,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodConstructHasResultArrayTheConfiguration() { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( array('basedn' => 'a') ); $this->assertType('array', $factory->getConfiguration()); @@ -58,7 +58,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet() { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( array('mock' => true) ); $this->assertType('Horde_Kolab_Server_Connection_Mock', $factory->getConnection()); @@ -72,7 +72,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodGetconnectionHasResultLdapConnectionIfConfiguredThatWay() { $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( array('basedn' => 'a') ); $this->assertType('Horde_Kolab_Server_Connection_Simpleldap', $factory->getConnection()); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php similarity index 79% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php index 7ecff3fb9..f6882c343 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php @@ -30,23 +30,23 @@ require_once dirname(__FILE__) . '/../../../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_InjectorTest +class Horde_Kolab_Server_Class_Server_Factory_Connection_InjectorTest extends PHPUnit_Framework_TestCase { public function testMethodGetconnectionHasResultConnection() { $injector = new Horde_Injector(new Horde_Injector_TopLevel()); $injector->bindImplementation( - 'Horde_Kolab_Server_Factory_Conn', - 'Horde_Kolab_Server_Factory_Conn_Mock' + 'Horde_Kolab_Server_Factory_Connection_Interface', + 'Horde_Kolab_Server_Factory_Connection_Mock' ); $injector->setInstance( 'Horde_Kolab_Server_Configuration', array() ); - $factory = new Horde_Kolab_Server_Factory_Conn_Injector($injector); + $factory = new Horde_Kolab_Server_Factory_Connection_Injector($injector); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php similarity index 87% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php index 880b81626..612f25cdb 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php @@ -30,12 +30,12 @@ require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_LdapTest +class Horde_Kolab_Server_Class_Server_Factory_Connection_LdapTest extends Horde_Kolab_Server_LdapTestCase { public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten() { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); $factory->setConfiguration( array( 'basedn' => 'test', @@ -53,7 +53,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodSetconfigurationHasPostconditionThatThePhpdnParameterWasRewritten() { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); $factory->setConfiguration( array( 'basedn' => 'test', @@ -71,7 +71,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodSetconfigurationHasPostconditionThatThePhppwParameterWasRewritten() { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); $factory->setConfiguration( array( 'basedn' => 'test', @@ -89,7 +89,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodSetconfigurationThrowsExceptionIfTheBasednIsNotSet() { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); try { $factory->setConfiguration(array()); $this->fail('No exception!'); @@ -104,7 +104,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodGetconnectionHasResultConnectionSimpleldap() { $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); $factory->setConfiguration(array('basedn' => 'test')); $this->assertType( 'Horde_Kolab_Server_Connection_Simpleldap', @@ -115,7 +115,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodGetconnectionHasResultConnectionSplittedldapIfTheHostMasterIsSet() { $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); $factory->setConfiguration(array('basedn' => 'test', 'host_master' => 'dummy')); $this->assertType( 'Horde_Kolab_Server_Connection_Splittedldap', diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php similarity index 86% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php index 5e741204a..844817084 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php @@ -30,12 +30,12 @@ require_once dirname(__FILE__) . '/../../../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_MockTest +class Horde_Kolab_Server_Class_Server_Factory_Connection_MockTest extends PHPUnit_Framework_TestCase { public function testMethodGetconfigurationHasResultArrayTheConnectionConfiguration() { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); $factory->setConfiguration(array('basedn' => 'test')); $this->assertEquals( array('basedn' => 'test'), @@ -45,7 +45,7 @@ extends PHPUnit_Framework_TestCase public function testMethodSetconfigurationHasPostconditionThatTheConfigurationWasSaved() { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); $factory->setConfiguration(array()); $this->assertEquals( array(), @@ -55,7 +55,7 @@ extends PHPUnit_Framework_TestCase public function testMethodGetconfigurationThrowsExceptionIfNoConfigurationHasBeenSet() { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); try { $factory->getConfiguration(); $this->fail('No exception!'); @@ -69,7 +69,7 @@ extends PHPUnit_Framework_TestCase public function testMethodGetconnectionHasResultConnectionmock() { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); $factory->setConfiguration( array( 'basedn' => 'test', diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php index 0fc37e604..8f0a65298 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php @@ -36,11 +36,21 @@ extends Horde_Kolab_Server_LdapTestCase public function setUp() { parent::setUp(); - $this->factory = $this->getMock('Horde_Kolab_Server_Factory_Conn'); - $this->objects = $this->getMock('Horde_Kolab_Server_Objects'); - $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface'); - $this->search = $this->getMock('Horde_Kolab_Server_Search_Interface'); - $this->schema = $this->getMock('Horde_Kolab_Server_Schema'); + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); + $this->objects = $this->getMock( + 'Horde_Kolab_Server_Objects_Interface' + ); + $this->structure = $this->getMock( + 'Horde_Kolab_Server_Structure_Interface' + ); + $this->search = $this->getMock( + 'Horde_Kolab_Server_Search_Interface' + ); + $this->schema = $this->getMock( + 'Horde_Kolab_Server_Schema_Interface' + ); } public function testMethodConstructHasParametersFactoryObjectsStructureSearchSchemaConfig() @@ -58,14 +68,16 @@ extends Horde_Kolab_Server_LdapTestCase ->method('getConnection') ->will( $this->returnValue( - $this->getMock('Horde_Kolab_Server_Connection') + $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ) ) ); $factory = new Horde_Kolab_Server_Factory_Constructor( $this->factory, $this->objects, $this->structure, $this->search, $this->schema, array('basedn' => 'test') ); - $this->assertType('Horde_Kolab_Server', $factory->getServer()); + $this->assertType('Horde_Kolab_Server_Interface', $factory->getServer()); } public function testMethodGetconfigurationReturnsArrayConfiguration() @@ -105,7 +117,9 @@ extends Horde_Kolab_Server_LdapTestCase ->method('getConnection') ->will( $this->returnValue( - $this->getMock('Horde_Kolab_Server_Connection') + $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ) ) ); $factory = new Horde_Kolab_Server_Factory_Constructor( @@ -113,7 +127,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->search, $this->schema, array('basedn' => 'test') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php similarity index 69% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php index 4a7a23477..f7bbadf48 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; +require_once dirname(__FILE__) . '/../../../../Autoload.php'; /** * Test the cleaner server factory. @@ -30,28 +30,39 @@ require_once dirname(__FILE__) . '/../../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_CleanerTest +class Horde_Kolab_Server_Class_Server_Factory_Decorator_CleanTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); } public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array('cleanup' => true) ); - $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Clean', + $factory->getServer() + ); } public function testMethodConstructHasParametersFactory() { - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory ); } @@ -60,7 +71,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getConnectionFactory(); @@ -70,8 +81,14 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getServer(); @@ -81,7 +98,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getConfiguration(); @@ -91,7 +108,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getConnection(); @@ -101,7 +118,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getComposite(); @@ -111,7 +128,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getObjects(); @@ -121,7 +138,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getStructure(); @@ -131,7 +148,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getSearch(); @@ -141,7 +158,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $this->factory, array() ); $factory->getSchema(); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php similarity index 70% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php index 9f299be6d..bb2b0f121 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; +require_once dirname(__FILE__) . '/../../../../Autoload.php'; /** * Test the log decorator server factory. @@ -30,28 +30,36 @@ require_once dirname(__FILE__) . '/../../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_LoggedTest +class Horde_Kolab_Server_Class_Server_Factory_Decorator_LogTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); } public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration() { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Logged( + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); - $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); + $this->assertType('Horde_Kolab_Server_Decorator_Log', $factory->getServer()); } public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter() { - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); } @@ -60,7 +68,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getConnectionFactory(); @@ -70,8 +78,14 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Logged( + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getServer(); @@ -81,7 +95,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getConfiguration(); @@ -91,7 +105,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getConnection(); @@ -101,7 +115,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getComposite(); @@ -111,7 +125,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getObjects(); @@ -121,7 +135,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getStructure(); @@ -131,7 +145,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getSearch(); @@ -141,7 +155,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $this->factory, 'logger' ); $factory->getSchema(); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php similarity index 70% rename from framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php rename to framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php index c2ea0b1e2..96688835e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php @@ -14,7 +14,7 @@ /** * Prepare the test setup. */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; +require_once dirname(__FILE__) . '/../../../../Autoload.php'; /** * Test the mapping server factory. @@ -30,28 +30,37 @@ require_once dirname(__FILE__) . '/../../../Autoload.php'; * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Class_Server_Factory_MappedTest +class Horde_Kolab_Server_Class_Server_Factory_Decorator_MapTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); } public function testMethodGetserverHasResultMappedServer() { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Mapped( + ->will( + $this->returnValue( + $this->getMock('Horde_Kolab_Server_Interface') + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); - $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Map', + $factory->getServer() + ); } public function testMethodConstructHasParametersFactoryAndArrayMapping() { - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); } @@ -60,7 +69,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getConnectionFactory(); @@ -70,8 +79,14 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Mapped( + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getServer(); @@ -81,7 +96,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getConfiguration(); @@ -91,7 +106,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getConnection(); @@ -101,7 +116,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getComposite(); @@ -111,7 +126,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getObjects(); @@ -121,7 +136,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getStructure(); @@ -131,7 +146,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getSearch(); @@ -141,7 +156,7 @@ extends PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $this->factory, array() ); $factory->getSchema(); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php index 024b50f3e..de20a2f81 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php @@ -37,7 +37,7 @@ extends Horde_Kolab_Server_LdapTestCase { $injector = new Horde_Injector(new Horde_Injector_TopLevel()); Horde_Kolab_Server_Factory_Injector::setup( - 'Horde_Kolab_Server_Factory_Conn_Mock', + 'Horde_Kolab_Server_Factory_Connection_Mock', $configuration, $injector ); @@ -49,7 +49,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodGetconnectionfactoryHasResultConnectionfactory() { $this->assertType( - 'Horde_Kolab_Server_Factory_Conn', + 'Horde_Kolab_Server_Factory_Connection_Interface', $this->_getFactory(array())->getConnectionFactory() ); } @@ -58,7 +58,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -101,7 +101,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', $factory->getObjects() ); } @@ -143,7 +143,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', $factory->getSchema() ); } @@ -153,7 +153,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->skipIfNoLdap(); $factory = $this->_getFactory(array('basedn' => 'test')); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php index e0bb3eb94..e5afa79f5 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php @@ -35,8 +35,12 @@ extends Horde_Kolab_Server_LdapTestCase { public function setUp() { - $this->conn_factory = $this->getMock('Horde_Kolab_Server_Factory_Conn'); - $this->connection = $this->getMock('Horde_Kolab_Server_Connection'); + $this->conn_factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); + $this->connection = $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ); } public function testMethodConstructHasParametersConnectionfactoryAndArrayParameters() @@ -74,7 +78,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->conn_factory, array() ); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -176,7 +180,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->conn_factory, array('basedn' => 'test') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php index a0c47bc69..fcbaf848e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php @@ -35,21 +35,21 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodConstructHasParameterServerobject() { $changes = new Horde_Kolab_Server_Ldap_Changes( - $this->getMock('Horde_Kolab_Server_Object'), array() + $this->getMock('Horde_Kolab_Server_Object_Interface'), array() ); } public function testMethodConstructHasParameterArrayDataToBeStored() { $changes = new Horde_Kolab_Server_Ldap_Changes( - $this->getMock('Horde_Kolab_Server_Object'), + $this->getMock('Horde_Kolab_Server_Object_Interface'), array('store' => 'value') ); } public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEmpty() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array())); @@ -61,7 +61,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEqual() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('a' => array('a')))); @@ -73,7 +73,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayNewAttributesInNewDatasetAsAdded() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array())); @@ -92,7 +92,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayMissingValuesInNewDatasetAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('old' => 'a'))); @@ -111,7 +111,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArraySingleValuesWithDifferencesAsReplaced() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => 'a'))); @@ -130,7 +130,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheNewValuesAsAdded() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); @@ -149,7 +149,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheRemovedValuesAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); @@ -168,7 +168,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheNewValuesAsAddedAndTheRemovedValuesAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php index 6316fe055..e6d7de9a5 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php @@ -265,9 +265,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -285,9 +283,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -305,9 +301,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -322,9 +316,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodSaveThrowsExceptionIfSavingDataFailed() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('modify') ->will($this->returnValue(new PEAR_Error('Saving failed!'))); @@ -342,9 +334,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasParameterObjectTheObjectToAddToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -353,9 +343,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasParameterArrayData() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -364,9 +352,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasPostconditionThatTheEntryWasModified() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -375,9 +361,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddThrowsExceptionIfSavingDataFailed() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->will($this->returnValue(new PEAR_Error('Saving failed!'))); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php index 0b10da10d..043060f5d 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php @@ -36,7 +36,7 @@ extends Horde_Kolab_Server_TestCase public function setUp() { $this->object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false + 'Horde_Kolab_Server_Object_Interface' ); $this->composite = $this->getMockedComposite(); } @@ -54,13 +54,16 @@ extends Horde_Kolab_Server_TestCase public function testMethodGetobjectReturnsObjectAssociatedWithThisAttribute() { $attribute = new Attribute_Mock($this->object, $this->composite, ''); - $this->assertType('Horde_Kolab_Server_Object', $attribute->getObject()); + $this->assertType( + 'Horde_Kolab_Server_Object_Interface', + $attribute->getObject() + ); } public function testMethodGetnameReturnsStringTheNameOfTheAttribute() { $this->composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('name') ->will($this->returnValue('name')); $attribute = new Attribute_Mock($this->object, $this->composite, 'name'); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php index 26932b5c7..32e2a8b21 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php @@ -74,7 +74,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('external'))); $object = new Object_Mock($composite, 'guid'); $this->assertEquals(array('external'), $object->getExternalAttributes()); @@ -85,7 +85,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $object = new Object_Mock($composite, 'guid'); $this->assertEquals(array('internal' => 'Internal'), $object->getInternalAttributes()); @@ -103,7 +103,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -118,7 +118,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -133,7 +133,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -150,7 +150,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -167,7 +167,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $object = new Object_Mock($composite, 'guid'); try { @@ -183,7 +183,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array('internal' => 'Internal', 'test' => 'Test') @@ -206,16 +206,16 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server { $composite = $this->getMockedComposite(); $composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('Objectclass') ->will($this->returnValue('objectClass')); $composite->schema->expects($this->exactly(1)) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('Objectclass'))); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('objectClass' => 'Objectclass'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -232,7 +232,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('external'))); $object = new Object_Mock($composite, 'guid'); try { @@ -248,7 +248,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('Test'))); $object = new Object_Mock($composite, 'guid'); try { @@ -274,7 +274,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(3)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array( @@ -295,12 +295,12 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server { $composite = $this->getMockedComposite(); $composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('Objectclass') ->will($this->returnValue('objectClass')); $composite->schema->expects($this->exactly(1)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array( @@ -324,7 +324,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server ); $composite->server->expects($this->exactly(1)) ->method('add') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object'), array('objectClass' => array('top'))); + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'), array('objectClass' => array('top'))); $object = new Object_Mock($composite); $object->save(array('Objectclass' => 'top')); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php index 9b5d05aa2..dd669a3f7 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php @@ -40,7 +40,6 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ ); } - public function testMethodConstructHasParameterQueryelementTheQueryCriteria() { $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); @@ -50,7 +49,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConstructHasPostconditionThatTheQueryCriteriaWereSaved() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure); @@ -63,7 +62,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodTostringHasResultStringTheQuery() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); @@ -78,7 +77,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertequealsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure); @@ -91,7 +90,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertbeginsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('begins')); $begins = new Horde_Kolab_Server_Query_Element_Begins('begins', 'begins'); $query = new Horde_Kolab_Server_Query_Ldap($begins, $this->structure); @@ -104,7 +103,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertendsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('ends')); $ends = new Horde_Kolab_Server_Query_Element_Ends('ends', 'ends'); $query = new Horde_Kolab_Server_Query_Ldap($ends, $this->structure); @@ -117,7 +116,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertcontainsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('contains')); $contains = new Horde_Kolab_Server_Query_Element_Contains('contains', 'contains'); $query = new Horde_Kolab_Server_Query_Ldap($contains, $this->structure); @@ -130,7 +129,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertlessHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('less')); $less = new Horde_Kolab_Server_Query_Element_Less('less', 'less'); $query = new Horde_Kolab_Server_Query_Ldap($less, $this->structure); @@ -143,7 +142,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertgreaterHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('greater')); $greater = new Horde_Kolab_Server_Query_Element_Greater('greater', 'greater'); $query = new Horde_Kolab_Server_Query_Ldap($greater, $this->structure); @@ -156,7 +155,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertapproxHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('approx')); $approx = new Horde_Kolab_Server_Query_Element_Approx('approx', 'approx'); $query = new Horde_Kolab_Server_Query_Ldap($approx, $this->structure); @@ -169,7 +168,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertnotHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $not = new Horde_Kolab_Server_Query_Element_Not($equals, $this->structure); @@ -183,7 +182,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertandHasResultNetldapfilter() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); @@ -198,7 +197,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertorHasResultNetldapfilter() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php index fd268c64d..0f605a369 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php @@ -57,37 +57,41 @@ extends PHPUnit_Framework_TestCase public function testMethodSearchguidHasResultArrayTheGuidsOfTheSearchResult() { - $result = $this->getMock('Horde_Kolab_Server_Result'); + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); $result->expects($this->once()) ->method('asArray') ->will($this->returnValue(array('a' => 'a'))); $this->structure->expects($this->once()) ->method('find') ->with( - $this->isInstanceOf('Horde_Kolab_Server_Query_Element'), + $this->isInstanceOf( + 'Horde_Kolab_Server_Query_Element_Interface' + ), array('attributes' => 'Guid') ) ->will($this->returnValue($result)); $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure); - $criteria = $this->getMock('Horde_Kolab_Server_Query_Element'); + $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface'); $this->assertEquals(array('a'), $search->searchGuid($criteria)); } public function testMethodSearchguidHasResultArrayEmptyIfTheSearchReturnedNoResults() { - $result = $this->getMock('Horde_Kolab_Server_Result'); + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); $result->expects($this->once()) ->method('asArray') ->will($this->returnValue(array())); $this->structure->expects($this->once()) ->method('find') ->with( - $this->isInstanceOf('Horde_Kolab_Server_Query_Element'), + $this->isInstanceOf( + 'Horde_Kolab_Server_Query_Element_Interface' + ), array('attributes' => 'Guid') ) ->will($this->returnValue($result)); $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure); - $criteria = $this->getMock('Horde_Kolab_Server_Query_Element'); + $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface'); $this->assertEquals(array(), $search->searchGuid($criteria)); } } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php index 5930dcc74..1864e9e8e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php @@ -34,13 +34,13 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew { public function setUp() { - $server = $this->getMock('Horde_Kolab_Server'); - $this->composite = new Horde_Kolab_Server_Composite( + $server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->composite = new Horde_Kolab_Server_Composite_Base( $server, - $this->getMock('Horde_Kolab_Server_Objects'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), new Horde_Kolab_Server_Structure_Kolab(), $this->getMock('Horde_Kolab_Server_Search_Interface'), - $this->getMock('Horde_Kolab_Server_Schema') + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } @@ -102,7 +102,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -135,7 +135,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -169,7 +169,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -203,7 +203,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -234,7 +234,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid,cn=external')) + ->with('searchGroupsForMember', array('guid,cn=external')) ->will( $this->returnValue( array( diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php index ac4a9908b..8b3220de6 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php @@ -34,13 +34,13 @@ class Horde_Kolab_Server_Class_Server_Structure_LdapTest extends Horde_Kolab_Ser { public function setUp() { - $server = $this->getMock('Horde_Kolab_Server'); - $this->composite = new Horde_Kolab_Server_Composite( + $server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->composite = new Horde_Kolab_Server_Composite_Base( $server, - $this->getMock('Horde_Kolab_Server_Objects'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), new Horde_Kolab_Server_Structure_Ldap(), $this->getMock('Horde_Kolab_Server_Search_Interface'), - $this->getMock('Horde_Kolab_Server_Schema') + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } @@ -170,7 +170,7 @@ class Horde_Kolab_Server_Class_Server_Structure_LdapTest extends Horde_Kolab_Ser { $structure = new Horde_Kolab_Server_Structure_Ldap(); try { - $structure->getInternalAttribute('undefined'); + $structure->mapExternalToInternalAttribute('undefined'); $this->fail('No exception!'); } catch (Horde_Kolab_Server_Exception $e) { $this->assertEquals( diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php b/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php index a4a7bcd0f..6de7c27e1 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php @@ -35,28 +35,18 @@ class Horde_Kolab_Server_TestCase extends PHPUnit_Framework_TestCase protected function getComposite() { return $this->getMock( - 'Horde_Kolab_Server_Composite', array(), array(), '', false + 'Horde_Kolab_Server_Composite_Interface' ); } protected function getMockedComposite() { - return new Horde_Kolab_Server_Composite( - $this->getMock( - 'Horde_Kolab_Server', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Objects', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Structure_Interface', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Search_Interface', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Schema', array(), array(), '', false - ) + return new Horde_Kolab_Server_Composite_Base( + $this->getMock('Horde_Kolab_Server_Interface'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), + $this->getMock('Horde_Kolab_Server_Structure_Interface'), + $this->getMock('Horde_Kolab_Server_Search_Interface'), + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } } \ No newline at end of file -- 2.11.0