1<?php 2/** 3 * Test the kolabExternalPop3Account object. 4 * 5 * PHP version 5 6 * 7 * @category Kolab 8 * @package Kolab_Server 9 * @author Gunnar Wrobel <wrobel@pardus.de> 10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 11 * @link http://pear.horde.org/index.php?package=Kolab_Server 12 */ 13 14/** 15 * Require our basic test case definition 16 */ 17require_once __DIR__ . '/Scenario.php'; 18 19/** 20 * Test the kolabExternalPop3Account object. 21 * 22 * Copyright 2009-2016 Horde LLC (http://www.horde.org/) 23 * 24 * See the enclosed file COPYING for license information (LGPL). If you 25 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 26 * 27 * @category Kolab 28 * @package Kolab_Server 29 * @author Gunnar Wrobel <wrobel@pardus.de> 30 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 31 * @link http://pear.horde.org/index.php?package=Kolab_Server 32 */ 33class Horde_Kolab_Server_Integration_Kolabpop3accountTest extends Horde_Kolab_Server_Integration_Scenario 34{ 35 /** 36 * Objects used within this test 37 * 38 * @var array 39 */ 40 private $objects = array( 41 /* Default bank account owner */ 42 array( 43 'type' => 'Horde_Kolab_Server_Object_Kolabinetorgperson', 44 'givenName' => 'Frank', 45 'Sn' => 'Mustermann', 46 'Userpassword' => 'Kolab_Server_OrgPersonTest_123', 47 ), 48 /* Default account */ 49 array( 50 'type' => 'Horde_Kolab_Server_Object_Kolabpop3account', 51 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL => 'frank@example.com', 52 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => 'pop.example.com', 53 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINNAME => 'frank', 54 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD => 'test', 55 ), 56 ); 57 58 /** 59 * Set up testing. 60 * 61 * @return NULL 62 */ 63 protected function setUp() 64 { 65 parent::setUp(); 66 67 $this->initializeEnvironments(); 68 $this->servers = $this->getKolabServers(); 69 } 70 71 /** 72 * Test ID generation for a person. 73 * 74 * @return NULL 75 */ 76 public function testGenerateId() 77 { 78 foreach ($this->servers as $server) { 79 $person = $this->assertAdd($server, $this->objects[0], 80 array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => '')); 81 $account_data = $this->objects[1]; 82 $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid(); 83 $a = new Horde_Kolab_Server_Object_Kolabpop3account($server, null, $account_data); 84 $this->assertContains(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL . '=' . $this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_MAIL], 85 $a->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_UID)); 86 } 87 } 88 89 /** 90 * Test adding an invalid Account. 91 * 92 * @expectedException Horde_Kolab_Server_Exception 93 * 94 * @return NULL 95 */ 96 public function testAddInvalidAccount() 97 { 98 $this->addToServers($this->objects[1]); 99 } 100 101 /** 102 * Test handling easy attributes. 103 * 104 * @return NULL 105 */ 106 public function testEasyAttributes() 107 { 108 foreach ($this->servers as $server) { 109 $person = $this->assertAdd($server, $this->objects[0], 110 array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => '')); 111 $account_data = $this->objects[1]; 112 $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid(); 113 $account = $this->assertAdd($server, $account_data, 114 array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID => $person->getUid())); 115 $this->assertEasyAttributes($account, $server, 116 array( 117 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PASSWORD => array( 118 'something', 119 'somewhere', 120 ), 121 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_DESCRIPTION => array( 122 'something', 123 'somewhere', 124 null, 125 '', 126 ), 127 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => array( 128 'something', 129 'somewhere', 130 array('a', 'b'), 131 ), 132 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_PORT => array( 133 '110', 134 '111', 135 null, 136 '', 137 ), 138 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USESSL => array( 139 'TRUE', 140 'FALSE', 141 null, 142 '', 143 ), 144 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_USETLS => array( 145 'TRUE', 146 'FALSE', 147 null, 148 '', 149 ), 150 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_LOGINMETHOD => array( 151 'something', 152 'somewhere', 153 null, 154 array('a', 'b'), 155 '', 156 ), 157 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_CHECKCERTIFICATE => array( 158 'TRUE', 159 'FALSE', 160 null, 161 '', 162 ), 163 Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_KEEPMAILONSERVER => array( 164 'TRUE', 165 'FALSE', 166 null, 167 '', 168 ), 169 ) 170 ); 171 } 172 } 173 174 /** 175 * Test modifying the attributes required for the UID of the account. This 176 * should lead to renaming object. 177 * 178 * @return NULL 179 */ 180 public function testModifyUidElements() 181 { 182 foreach ($this->servers as $server) { 183 $person = $this->assertAdd($server, $this->objects[0], 184 array(Horde_Kolab_Server_Object_Kolabinetorgperson::ATTRIBUTE_SID => '')); 185 $account_data = $this->objects[1]; 186 $account_data[Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_OWNERUID] = $person->getUid(); 187 $account = $server->add($account_data); 188 $account = $server->fetch($account->getUid()); 189 190 $this->assertEquals($this->objects[1][Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER], 191 $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER)); 192 193 $result = $account->save(array(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER => 'pop3s.example.com')); 194 195 $account = $server->fetch($account->getUid()); 196 197 $this->assertContains( 198 'pop3s.example.com', 199 $account->get(Horde_Kolab_Server_Object_Kolabpop3account::ATTRIBUTE_SERVER, false) 200 ); 201 202 $this->assertContains('frank@example.com', $account->getUid()); 203 204 $result = $server->delete($account->getUid()); 205 } 206 } 207} 208