--- /dev/null
+<?php
+/*
+ * Unit tests for the horde backend
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @package Horde_ActiveSync
+ */
+class Horde_ActiveSync_ContactTest extends Horde_Test_Case
+{
+ public function testBlah()
+ {
+ $this->markTestIncomplete();
+ }
+}
* @category Horde
* @package Horde_ActiveSync
*/
-require_once dirname(__FILE__) . '/fixtures/MockConnector.php';
-
//FIXME: This can be removed once all the constants are class-constants
require_once dirname(__FILE__) . '/../../../lib/Horde/ActiveSync.php';
class Horde_ActiveSync_FileStateTest extends Horde_Test_Case
*/
public function testCollectionSyncState()
{
- $contact = array(
- '__key' => '9b07c14b086932e69cc7eb1baed0cc87',
- '__owner' => 'mike',
- '__type' => 'Object',
- '__members' => '',
- '__uid' => '20070112030611.62g1lg5nry80@test.theupstairsroom.com',
- 'firstname' => 'Michael',
- 'lastname' => 'Rubinsky',
- 'middlenames' => 'Joseph',
- 'namePrefix' => 'Dr',
- 'nameSuffix' => 'PharmD',
- 'name' => 'Michael Joseph Rubinsky',
- 'alias' => 'Me',
- 'birthday' => '1970-03-20',
- 'homeStreet' => '123 Main St.',
- 'homePOBox' => '',
- 'homeCity' => 'Anywhere',
- 'homeProvince' => 'NJ',
- 'homePostalCode' => '08080',
- 'homeCountry' => 'US',
- 'workStreet' => 'Kings Hwy',
- 'workPOBox' => '',
- 'workCity' => 'Somewhere',
- 'workProvince' => 'NJ',
- 'workPostalCode' => '08052',
- 'workCountry' => 'US',
- 'timezone' => 'America/New_York',
- 'email' => 'mrubinsk@horde.org',
- 'homePhone' => '(856)555-1234',
- 'workPhone' => '(856)555-5678',
- 'cellPhone' => '(609)555-9876',
- 'fax' => '',
- 'pager' => '',
- 'title' => '',
- 'role' => '',
- 'company' => '',
- 'category' => '',
- 'notes' => '',
- 'website' => '',
- 'freebusyUrl' => '',
- 'pgpPublicKey' => '',
- 'smimePublicKey' => '',
- );
-
/* Create a mock driver with desired return values */
$fixture = array('contacts_list' => array('20070112030611.62g1lg5nry80@test.theupstairsroom.com'),
- 'contacts_getActionTimestamp' => 0,
- 'contacts_export' => $contact);
- $connector = new Horde_ActiveSync_MockConnector(array('fixture' => $fixture));
+ 'contacts_getActionTimestamp' => 0);
+
+ $connector = $this->getMockSkipConstructor('Horde_ActiveSync_Driver_Horde_Connector_Registry');
+ $connector->expects($this->exactly(2))
+ ->method('contacts_list')
+ ->will($this->returnValue($fixture['contacts_list']));
+
+ $connector->expects($this->exactly(1))
+ ->method('contacts_getActionTimestamp')
+ ->will($this->returnValue($fixture['contacts_getActionTimestamp']));
+
$state = new Horde_ActiveSync_State_File(array('stateDir' => './'));
$driver = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
'state_basic' => $state));
* @category Horde
* @package Horde_ActiveSync
*/
-require_once dirname(__FILE__) . '/fixtures/MockConnector.php';
class Horde_ActiveSync_HordeDriverTest extends Horde_Test_Case
{
/**
/**
* Test that Horde_ActiveSync_Driver_Horde#getMessageList() returns expected
- * data structures. Uses mock data via the MockConnector
+ * data structures.
*
*/
public function testGetMessageList()
{
// Test Contacts - simulates returning two contacts, both of which have no history modify entries.
$fixture = array('contacts_list' => array('20070112030603.249j42k3k068@test.theupstairsroom.com',
- '20070112030611.62g1lg5nry80@test.theupstairsroom.com'),
+ '20070112030611.62g1lg5nry80@test.theupstairsroom.com'),
'contacts_getActionTimestamp' => 0);
- $connector = new Horde_ActiveSync_MockConnector(array('fixture' => $fixture));
+ $connector = $this->getMockSkipConstructor('Horde_ActiveSync_Driver_Horde_Connector_Registry');
+ $connector->expects($this->once())->method('contacts_list')->will($this->returnValue($fixture['contacts_list']));
+ $connector->expects($this->exactly(2))->method('contacts_getActionTimestamp')->will($this->returnValue($fixture['contacts_getActionTimestamp']));
+
$state = $this->getMockSkipConstructor('Horde_ActiveSync_State_File');
$driver = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
'state_basic' => $state));
}
/* Mock the registry connector */
- $fixture = array(
- 'contacts_export' => $contact,
- 'calendar_export' => $event,
- 'tasks_export' => $task
- );
- $connector = new Horde_ActiveSync_MockConnector(array('fixture' => $fixture));
+ $connector = $this->getMockSkipConstructor('Horde_ActiveSync_Driver_Horde_Connector_Registry');
+ $connector->expects($this->once())
+ ->method('contacts_export')
+ ->will($this->returnValue($contact));
+
+ $connector->expects($this->once())
+ ->method('calendar_export')
+ ->will($this->returnValue($event));
+
+ $connector->expects($this->once())
+ ->method('tasks_export')
+ ->will($this->returnValue($task));
/* We don't need to remember any state for this test, mock it */
$state = $this->getMockSkipConstructor('Horde_ActiveSync_State_File');
$this->markTestIncomplete('Test still being written');
/* Setup mock connector method return values for adding a new contact */
$connector = $this->getMockSkipConstructor('Horde_ActiveSync_Driver_Horde_Connector_Registry');
- $connector->expects($this->once())->method('contacts_import')->will($this->returnValue(1));
- $connector->expects($this->at(1))->method('contacts_getActionTimestamp')->will($this->returnValue(array('todo')));
+ $connector->expects($this->once())
+ ->method('contacts_import')
+ ->will($this->returnValue(1));
+
+ $connector->expects($this->at(1))
+ ->method('contacts_getActionTimestamp')
+ ->will($this->returnValue(array('todo')));
/* Setup mock connector return for modifying an existing contact */
- $connector->expects($this->once())->method('contacts_replace')->will($this->returnValue(2));
- $connector->expects($this->at(1))->method('contacts_getActionTimestamp')->will($this->returnValue(array('todo')));
+ $connector->expects($this->once())
+ ->method('contacts_replace')
+ ->will($this->returnValue(2));
+
+ $connector->expects($this->at(1))
+ ->method('contacts_getActionTimestamp')
+ ->will($this->returnValue(array('todo')));
/* TODO: appointments and todos */
{
$registry = $this->getMockSkipConstructor('Horde_Registry');
$state = $this->getMockSkipConstructor('Horde_ActiveSync_State_File');
- $connector = new Horde_ActiveSync_MockConnector(array('fixture' => array('horde_listApis' => array('horde', 'contacts', 'calendar', 'tasks'))));
+
+ /* Mock registry connector */
+ $connector = $this->getMockSkipConstructor('Horde_ActiveSync_Driver_Horde_Connector_Registry');
+ $connector->expects($this->once())
+ ->method('horde_listApis')
+ ->will($this->returnValue(array('horde', 'contacts', 'calendar', 'tasks')));
+
$driver = new Horde_ActiveSync_Driver_Horde(array('connector' => $connector,
'state_basic' => $state));
$results = $driver->getFolderList();
+++ /dev/null
-<?php
-/**
- * Mock connector for unit testing horde backend.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @package Horde_ActiveSync
- */
-class Horde_ActiveSync_MockConnector
-{
- public function __construct($params = array())
- {
- $this->_fixture = $params['fixture'];
- }
-
- public function __call($name, $args)
- {
- if (empty($this->_fixture[$name])) {
- return 0;
- }
- return $this->_fixture[$name];
- }
-
- public function contacts_import($content)
- {
- // $content is a vCard that should eq:
- $expected = array(
- 'firstname' => 'Michael',
- 'lastname' => 'Rubinsky',
- 'middlenames' => 'Joseph',
- 'namePrefix' => '',
- 'nameSuffix' => '',
- 'name' => 'Michael Joseph Rubinsky',
- 'birthday' => '1970-03-20',
- 'homeStreet' => '123 Main St.',
- 'homeCity' => 'Anywhere',
- 'homeProvince' => 'NJ',
- 'homePostalCode' => '08080',
- 'homeCountry' => '',
- 'workStreet' => '',
- 'workCity' => '',
- 'workProvince' => '',
- 'workCountry' => '',
- //'timezone' => '',
- 'email' => 'mrubinsk@horde.org',
- 'homePhone' => '(856)555-1234',
- 'workPhone' => '(856)555-5678',
- 'cellPhone' => '(609)555-9876',
- 'fax' => '',
- 'pager' => '',
- 'title' => '',
- 'company' => '',
- //'category' => '',
- 'notes' => '',
- 'website' => '',
- );
-
- foreach ($expected as $key => $value) {
- if ($content[$key] != $value) {
- throw new Horde_ActiveSync_Exception('Expected value ' . $value . ' did not match received value ' . $content[$key]);
- }
- }
-
- return 'xx.xx@localhost';
- }
-
- public function contacts_replace()
- {
-
- }
-
- public function calendar_import()
- {
-
- }
-}
\ No newline at end of file