From: Gunnar Wrobel Date: Wed, 28 Oct 2009 08:30:24 +0000 (+0100) Subject: Completed the factory testing. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=799385cf55e631e94aabe27452abd0b9f56dab56;p=horde.git Completed the factory testing. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php deleted file mode 100644 index 576445308..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaned.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory decorator that adds cleaning 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_Cleaned -implements Horde_Kolab_Server_Factory -{ - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Server_Factory - */ - private $_factory; - - /** - * Constructor. - * - * @param Horde_Kolab_Server_Factory $factory The base factory. - */ - public function __construct(Horde_Kolab_Server_Factory $factory) - { - $this->_factory = $factory; - $this->_mapping = $mapping; - } - - /** - * 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_Cleaned($server); - 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/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php new file mode 100644 index 000000000..9c791082d --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php @@ -0,0 +1,143 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds cleaning 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_Cleaner +implements Horde_Kolab_Server_Factory +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + */ + public function __construct(Horde_Kolab_Server_Factory $factory) + { + $this->_factory = $factory; + } + + /** + * 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_Cleaner($server); + 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/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php index 2a07597ec..c54ca489e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php @@ -66,8 +66,8 @@ implements Horde_Kolab_Server_Factory } if (!empty($config['cleanup'])) { - $factory = new Horde_Kolab_Server_Factory_Cleaned( - $factory, $config['map'] + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory ); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php index 81fb120dc..3e2e7d7e4 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php @@ -28,6 +28,13 @@ interface Horde_Kolab_Server_Factory_Conn { /** + * Get the connection configuration. + * + * @return array $configuration The configuration parameters. + */ + public function getConfiguration(); + + /** * Set the connection configuration. * * @param array $configuration The configuration parameters. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php index 3c96143a3..1336cbdff 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php @@ -36,6 +36,21 @@ implements Horde_Kolab_Server_Factory_Conn private $_configuration; /** + * Get the connection configuration. + * + * @return array $configuration The configuration parameters. + */ + public function getConfiguration() + { + if (!isset($this->_configuration)) { + throw new Horde_Kolab_Server_Exception( + 'The configuration has not been set!' + ); + } + return $this->_configuration; + } + + /** * Set the connection configuration. * * @param array $configuration The configuration parameters. @@ -44,25 +59,6 @@ implements Horde_Kolab_Server_Factory_Conn */ public function setConfiguration(array $configuration) { - if (!isset($configuration['basedn'])) { - throw new Horde_Kolab_Server_Exception('The base DN is missing'); - } - - if (isset($configuration['server'])) { - $configuration['host'] = $configuration['server']; - unset($configuration['server']); - } - - if (isset($configuration['phpdn'])) { - $configuration['binddn'] = $configuration['phpdn']; - unset($configuration['phpdn']); - } - - if (isset($configuration['phppw'])) { - $configuration['bindpw'] = $configuration['phppw']; - unset($configuration['phppw']); - } - $this->_configuration = $configuration; } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php index f53b1a94c..f483de804 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php @@ -29,16 +29,48 @@ class Horde_Kolab_Server_Factory_Conn_Ldap extends Horde_Kolab_Server_Factory_Conn_Base { /** + * Set the connection configuration. + * + * @param array $configuration The configuration parameters. + * + * @return NULL + */ + public function setConfiguration(array $configuration) + { + if (!isset($configuration['basedn'])) { + throw new Horde_Kolab_Server_Exception('The base DN is missing!'); + } + + if (isset($configuration['server'])) { + $configuration['host'] = $configuration['server']; + unset($configuration['server']); + } + + if (isset($configuration['phpdn'])) { + $configuration['binddn'] = $configuration['phpdn']; + unset($configuration['phpdn']); + } + + if (isset($configuration['phppw'])) { + $configuration['bindpw'] = $configuration['phppw']; + unset($configuration['phppw']); + } + + parent::setConfiguration($configuration); + } + + /** * Return the server connection that should be used. * * @return Horde_Kolab_Server_Connection The server connection. */ public function getConnection() { - $ldap_read = new Net_LDAP2($params); - if (isset($params['host_master'])) { - $params['host'] = $params['host_master']; - $ldap_write = new Net_LDAP2($params); + $configuration = $this->getConfiguration(); + $ldap_read = new Net_LDAP2($configuration); + if (isset($configuration['host_master'])) { + $configuration['host'] = $configuration['host_master']; + $ldap_write = new Net_LDAP2($configuration); $connection = new Horde_Kolab_Server_Connection_Splittedldap( $ldap_read, $ldap_write ); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php index 5cbdcf4ed..8578f50e8 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php @@ -36,7 +36,7 @@ extends Horde_Kolab_Server_Factory_Conn_Base public function getConnection() { $connection = new Horde_Kolab_Server_Connection_Mock( - $this->_configuration + $this->getConfiguration() ); return $connection; } 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 1e03e7a06..0699c40c0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php @@ -29,20 +29,6 @@ class Horde_Kolab_Server_Factory_Injector implements Horde_Kolab_Server_Factory { /** - * The conn factory class. - * - * @param string - */ - private $_conn_factory; - - /** - * Configuration parameters for the server. - * - * @var array - */ - private $_configuration; - - /** * The injector. * * @var Horde_Injector @@ -57,8 +43,6 @@ implements Horde_Kolab_Server_Factory public function __construct( Horde_Injector $injector ) { - $this->_conn_factory = $factory; - $this->_configuration = $config; $this->_injector = $injector; $this->_setup(); } @@ -95,7 +79,7 @@ implements Horde_Kolab_Server_Factory Horde_Injector $injector ) { $injector->setInstance( - 'Horde_Kolab_Server_Config', $config + 'Horde_Kolab_Server_Configuration', $config ); } @@ -179,13 +163,14 @@ implements Horde_Kolab_Server_Factory */ private function _setupStructure() { - if (!isset($this->_configuration['structure']['driver'])) { + $configuration = $this->getConfiguration(); + if (!isset($configuration['structure']['driver'])) { $driver = 'Horde_Kolab_Server_Structure_Kolab'; } else { - $driver = $this->_configuration['structure']['driver']; + $driver = $configuration['structure']['driver']; } - $injector->bindImplementation('Horde_Kolab_Server_Structure', $driver); + $this->_injector->bindImplementation('Horde_Kolab_Server_Structure', $driver); } /** @@ -195,7 +180,7 @@ implements Horde_Kolab_Server_Factory */ private function _setupConnection() { - $injector->bindFactory( + $this->_injector->bindFactory( 'Horde_Kolab_Server_Connection', 'Horde_Kolab_Server_Factory_Conn_Injector', 'getConnection' @@ -209,7 +194,7 @@ implements Horde_Kolab_Server_Factory */ private function _setupServer() { - $injector->bindFactory( + $this->_injector->bindFactory( 'Horde_Kolab_Server', 'Horde_Kolab_Server_Factory_Injector', 'getServer' @@ -267,7 +252,7 @@ implements Horde_Kolab_Server_Factory { $configuration = $this->getConfiguration(); if (!isset($configuration['basedn'])) { - throw new Horde_Kolab_Server_Exception('The base DN is missing'); + throw new Horde_Kolab_Server_Exception('The base DN is missing!'); } $connection = $this->getConnection(); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php index 54cca83f8..b177ed3f0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php @@ -82,7 +82,9 @@ implements Horde_Kolab_Server_Factory public function getServer() { $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Logged($server); + $server = new Horde_Kolab_Server_Logged( + $server, $this->_logger + ); return $server; } diff --git a/framework/Kolab_Server/package.xml b/framework/Kolab_Server/package.xml index 7d27db5cb..efafca52b 100644 --- a/framework/Kolab_Server/package.xml +++ b/framework/Kolab_Server/package.xml @@ -61,6 +61,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -79,7 +80,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + @@ -303,6 +304,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -314,7 +316,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php b/framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php index 73997e561..02ca6779c 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/AllTests.php @@ -57,9 +57,6 @@ class Horde_Kolab_Server_AllTests */ public static function suite() { - // Catch strict standards - error_reporting(E_ALL | E_STRICT); - $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Kolab_Server'); $basedir = dirname(__FILE__); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php index 780b43c8c..f71c887b7 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Autoload.php @@ -22,4 +22,7 @@ if (!spl_autoload_functions()) { . 'error_reporting($oldErrorReporting);' ) ); -} \ No newline at end of file +} + +/** Catch strict standards */ +error_reporting(E_ALL | E_STRICT); 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/CleanerTest.php new file mode 100644 index 000000000..4a7a23477 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php @@ -0,0 +1,149 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the cleaner server factory. + * + * 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_Class_Server_Factory_CleanerTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + } + + 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( + $this->factory, array('cleanup' => true) + ); + $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); + } + + public function testMethodConstructHasParametersFactory() + { + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Cleaner( + $this->factory, array() + ); + $factory->getSchema(); + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..8ba5eb91c --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php @@ -0,0 +1,170 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the configuration based server factory. + * + * 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_Class_Server_Factory_ConfigurationTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + } + + public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array('logger' => 'set') + ); + $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); + } + + public function testMethodGetserverHasResultMappedServerIfAMappedWasProvidedInTheConfiguration() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array('map' => array()) + ); + $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); + } + + public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array('cleanup' => true) + ); + $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); + } + + public function testMethodConstructHasParametersFactoryAndArrayParameters() + { + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Configuration( + $this->factory, array() + ); + $factory->getSchema(); + } +} \ No newline at end of file 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/Conn/InjectorTest.php new file mode 100644 index 000000000..7ecff3fb9 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php @@ -0,0 +1,53 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the injector based connection factory. + * + * 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_Class_Server_Factory_Conn_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' + ); + $injector->setInstance( + 'Horde_Kolab_Server_Configuration', + array() + ); + $factory = new Horde_Kolab_Server_Factory_Conn_Injector($injector); + $this->assertType( + 'Horde_Kolab_Server_Connection', + $factory->getConnection() + ); + } +} \ No newline at end of file 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/Conn/LdapTest.php new file mode 100644 index 000000000..7f2aaa9f1 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php @@ -0,0 +1,123 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the ldap connection factory. + * + * 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_Class_Server_Factory_Conn_LdapTest +extends PHPUnit_Framework_TestCase +{ + public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'server' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'host' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatThePhpdnParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'phpdn' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'binddn' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatThePhppwParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'phppw' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'bindpw' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationThrowsExceptionIfTheBasednIsNotSet() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + try { + $factory->setConfiguration(array()); + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'The base DN is missing!', + $e->getMessage() + ); + } + } + + public function testMethodGetconnectionHasResultConnectionSimpleldap() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory->setConfiguration(array('basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Connection_Simpleldap', + $factory->getConnection() + ); + } + + public function testMethodGetconnectionHasResultConnectionSplittedldapIfTheHostMasterIsSet() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); + $factory->setConfiguration(array('basedn' => 'test', 'host_master' => 'dummy')); + $this->assertType( + 'Horde_Kolab_Server_Connection_Splittedldap', + $factory->getConnection() + ); + } +} \ No newline at end of file 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/Conn/MockTest.php new file mode 100644 index 000000000..a5518794f --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php @@ -0,0 +1,79 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the mock connection factory. + * + * 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_Class_Server_Factory_Conn_MockTest +extends PHPUnit_Framework_TestCase +{ + public function testMethodGetconfigurationHasResultArrayTheConnectionConfiguration() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory->setConfiguration(array('basedn' => 'test')); + $this->assertEquals( + array('basedn' => 'test'), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatTheConfigurationWasSaved() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory->setConfiguration(array()); + $this->assertEquals( + array(), + $factory->getConfiguration() + ); + } + + public function testMethodGetconfigurationThrowsExceptionIfNoConfigurationHasBeenSet() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + try { + $factory->getConfiguration(); + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'The configuration has not been set!', + $e->getMessage() + ); + } + } + + public function testMethodGetconnectionHasResultConnectionmock() + { + $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); + $factory->setConfiguration(array('basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Connection_Mock', + $factory->getConnection() + ); + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..59f42df6e --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php @@ -0,0 +1,153 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the mapping server factory. + * + * 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_Class_Server_Factory_ConstructorTest +extends PHPUnit_Framework_TestCase +{ + public function 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'); + $this->search = $this->getMock('Horde_Kolab_Server_Search'); + $this->schema = $this->getMock('Horde_Kolab_Server_Schema'); + } + + public function testMethodConstructHasParametersFactoryObjectsStructureSearchSchemaConfig() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + } + + public function testMethodGetserverReturnsServer() + { + $this->factory->expects($this->once()) + ->method('getConnection') + ->will( + $this->returnValue( + $this->getMock('Horde_Kolab_Server_Connection') + ) + ); + $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()); + } + + public function testMethodGetconfigurationReturnsArrayConfiguration() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + $this->assertEquals( + array('basedn' => 'test'), $factory->getConfiguration() + ); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection') + ->will( + $this->returnValue( + $this->getMock('Horde_Kolab_Server_Connection') + ) + ); + $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_Connection', + $factory->getConnection() + ); + } + + public function testMethodGetcompositeReturnsComposite() + { + $this->factory->expects($this->once()) + ->method('getConnection') + ->will( + $this->returnValue( + $this->getMock('Horde_Kolab_Server_Connection') + ) + ); + $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_Composite', + $factory->getComposite() + ); + } + + public function testMethodGetobjectsReturnsObjects() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + $this->assertSame($this->objects, $factory->getObjects()); + } + + public function testMethodGetstructureReturnsStructure() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + $this->assertSame($this->structure, $factory->getStructure()); + } + + public function testMethodGetsearchReturnsSearch() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + $this->assertSame($this->search, $factory->getSearch()); + } + + public function testMethodGetschemaGetsDelegated() + { + $factory = new Horde_Kolab_Server_Factory_Constructor( + $this->factory, $this->objects, $this->structure, + $this->search, $this->schema, array('basedn' => 'test') + ); + $this->assertSame($this->schema, $factory->getSchema()); + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..8dadfb108 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php @@ -0,0 +1,158 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the injector based server factory. + * + * 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_Class_Server_Factory_InjectorTest +extends PHPUnit_Framework_TestCase +{ + private function _getFactory(array $configuration = array()) + { + $injector = new Horde_Injector(new Horde_Injector_TopLevel()); + Horde_Kolab_Server_Factory_Injector::setup( + 'Horde_Kolab_Server_Factory_Conn_Mock', + $configuration, + $injector + ); + return $injector->getInstance( + 'Horde_Kolab_Server_Factory_Injector' + ); + } + + public function testMethodGetconnectionfactoryHasResultConnectionfactory() + { + $this->assertType( + 'Horde_Kolab_Server_Factory_Conn', + $this->_getFactory(array())->getConnectionFactory() + ); + } + + public function testMethodGetconnectionHasResultConnection() + { + $factory = $this->_getFactory(array()); + $this->assertType( + 'Horde_Kolab_Server_Connection', + $factory->getConnection() + ); + } + + public function testMethodGetserverHasResultServerldapstandard() + { + $factory = $this->_getFactory(array('basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Ldap_Standard', + $factory->getServer() + ); + } + + public function testMethodGetserverThrowsExceptionIfTheBaseDnIsMissingInTheConfiguration() + { + $factory = $this->_getFactory(array()); + try { + $factory->getServer(); + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'The base DN is missing!', + $e->getMessage() + ); + } + } + + public function testMethodGetserverHasResultServerldapFilteredIfAFilterWasSet() + { + $factory = $this->_getFactory(array('filter' => 'test', 'basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Ldap_Filtered', + $factory->getServer() + ); + } + + public function testMethodGetobjectsHasResultObjects() + { + $factory = $this->_getFactory(array()); + $this->assertType( + 'Horde_Kolab_Server_Objects', + $factory->getObjects() + ); + } + + public function testMethodGetstructureHasResultStructureKolab() + { + $factory = $this->_getFactory(array()); + $this->assertType( + 'Horde_Kolab_Server_Structure_Kolab', + $factory->getStructure() + ); + } + + public function testMethodGetstructureHasResultStructureLdapIfConfiguredThatWay() + { + $factory = $this->_getFactory( + array( + 'structure' => array( + 'driver' => 'Horde_Kolab_Server_Structure_Ldap' + ) + ) + ); + $this->assertType( + 'Horde_Kolab_Server_Structure_Ldap', + $factory->getStructure() + ); + } + + public function testMethodGetsearchHasResultSearch() + { + $factory = $this->_getFactory(array()); + $this->assertType( + 'Horde_Kolab_Server_Search', + $factory->getSearch() + ); + } + + public function testMethodGetschemaHasResultSchema() + { + $factory = $this->_getFactory(array()); + $this->assertType( + 'Horde_Kolab_Server_Schema', + $factory->getSchema() + ); + } + + public function testMethodGetcompositeHasResultComposite() + { + $factory = $this->_getFactory(array('basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Composite', + $factory->getComposite() + ); + } + +} \ No newline at end of file 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/LoggedTest.php new file mode 100644 index 000000000..9f299be6d --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php @@ -0,0 +1,149 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the log decorator server factory. + * + * 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_Class_Server_Factory_LoggedTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + } + + 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( + $this->factory, 'logger' + ); + $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); + } + + public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter() + { + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Logged( + $this->factory, 'logger' + ); + $factory->getSchema(); + } +} \ No newline at end of file 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/MappedTest.php new file mode 100644 index 000000000..c2ea0b1e2 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php @@ -0,0 +1,149 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the mapping server factory. + * + * 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_Class_Server_Factory_MappedTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); + } + + 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( + $this->factory, array() + ); + $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); + } + + public function testMethodConstructHasParametersFactoryAndArrayMapping() + { + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Mapped( + $this->factory, array() + ); + $factory->getSchema(); + } +} \ No newline at end of file