/usr/share/php/tests/turba/Turba/TestCase.php is in php-horde-turba 4.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | <?php
/**
* Basic Turba test case.
*
* PHP version 5
*
* @category Horde
* @package Turba
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/turba
* @license http://www.horde.org/licenses/apache Apache-like
*/
/**
* Basic Turba test case.
*
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you did
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @category Horde
* @package Turba
* @subpackage UnitTests
* @author Gunnar Wrobel <wrobel@pardus.de>
* @link http://www.horde.org/apps/turba
* @license http://www.horde.org/licenses/apache Apache-like
*/
class Turba_TestCase extends PHPUnit_Framework_TestCase
{
protected function getInjector()
{
return new Horde_Injector(new Horde_Injector_TopLevel());
}
static protected function createBasicTurbaSetup(Horde_Test_Setup $setup)
{
$setup->setup(
array(
'_PARAMS' => array(
'user' => 'test@example.com',
'app' => 'turba'
),
'Horde_Prefs' => 'Prefs',
'Horde_Perms' => 'Perms',
'Horde_Group' => 'Group',
'Horde_History' => 'History',
'Horde_Registry' => 'Registry',
)
);
$setup->makeGlobal(
array(
'prefs' => 'Horde_Prefs',
'registry' => 'Horde_Registry',
'injector' => 'Horde_Injector',
)
);
$GLOBALS['session'] = new Horde_Session();
$GLOBALS['conf']['prefs']['driver'] = 'Null';
}
static protected function tearDownBasicTurbaSetup()
{
unset(
$GLOBALS['session'],
$GLOBALS['prefs'],
$GLOBALS['injector'],
$GLOBALS['registry'],
$GLOBALS['conf']
);
}
static protected function createSqlPdoSqlite(Horde_Test_Setup $setup)
{
$setup->setup(
array(
'Horde_Db_Adapter' => array(
'factory' => 'Db',
'params' => array(
'migrations' => array(
'migrationsPath' => __DIR__ . '/../../migration',
'schemaTableName' => 'turba_test_schema'
)
)
),
)
);
}
static protected function createSqlShares(Horde_Test_Setup $setup)
{
$setup->getInjector()->setInstance(
'Horde_Core_Factory_Db',
new Horde_Test_Stub_Factory(
$setup->getInjector()->getInstance('Horde_Db_Adapter')
)
);
$setup->setup(
array(
'Turba_Shares' => 'Share',
)
);
$GLOBALS['cfgSources']['test']['type'] = 'Sql';
$GLOBALS['cfgSources']['test']['title'] = 'SQL';
$GLOBALS['cfgSources']['test']['map'] = self::_getSqlMap();
}
static protected function createKolabShares(Horde_Test_Setup $setup)
{
$setup->setup(
array(
'Horde_Kolab_Storage' => array(
'factory' => 'KolabStorage',
'params' => array(
'imapuser' => 'test',
)
),
'Turba_Shares' => array(
'factory' => 'Share',
'method' => 'Kolab',
),
)
);
$setup->getInjector()->setInstance(
'Horde_Core_Factory_Share',
new Horde_Test_Stub_Factory(
$setup->getInjector()->getInstance('Turba_Shares')
)
);
$GLOBALS['cfgSources']['test']['type'] = 'Kolab';
$GLOBALS['cfgSources']['test']['title'] = 'Kolab';
$GLOBALS['cfgSources']['test']['map'] = self::_getKolabMap();
}
static protected function tearDownShares()
{
unset(
$GLOBALS['cfgSources']
);
}
static protected function getKolabDriver()
{
$setup = new Horde_Test_Setup();
self::createBasicTurbaSetup($setup);
return self::createKolabDriverWithShares();
}
static protected function createKolabDriverWithShares($setup)
{
self::createKolabShares($setup);
list($share, $other_share) = self::_createDefaultShares();
$GLOBALS['cfgSources'][$share->getName()]['type'] = 'Kolab';
$GLOBALS['cfgSources'][$share->getName()]['title'] = $share->get('name');
$GLOBALS['cfgSources'][$share->getName()]['map'] = self::_getKolabMap();
return $GLOBALS['injector']->getInstance('Turba_Factory_Driver')
->create($share->getName());
}
static protected function createSqlDriverWithShares($setup)
{
self::createSqlShares($setup);
list($share, $other_share) = self::_createDefaultShares();
$GLOBALS['cfgSources'][$share->getName()]['type'] = 'Sql';
$GLOBALS['cfgSources'][$share->getName()]['title'] = $share->get('name');
$GLOBALS['cfgSources'][$share->getName()]['map'] = self::_getSqlMap();
$GLOBALS['cfgSources'][$share->getName()]['params']['table'] = 'turba_objects';
return $GLOBALS['injector']->getInstance('Turba_Factory_Driver')
->create($share->getName());
}
static protected function _createDefaultShares()
{
$share = self::_createShare(
'Address book of Tester', 'test@example.com'
);
$other_share = self::_createShare(
'Other address book of Tester', 'test@example.com'
);
return array($share, $other_share);
}
static private function _createShare($name, $owner)
{
$turba_shares = $GLOBALS['injector']->getInstance('Turba_Shares');
$share = $turba_shares->newShare(
$owner, strval(new Horde_Support_Randomid()), $name
);
$turba_shares->addShare($share);
return $share;
}
static private function _getKolabMap()
{
return array(
'__key' => 'uid',
'__uid' => 'uid',
'__type' => '__type',
'__members' => '__members',
/* Personal */
'name' => array(
'fields' => array('firstname', 'middlenames', 'lastname'),
'format' => '%s %s %s',
'parse' => array(
array(
'fields' => array(
'firstname', 'middlenames', 'lastname'
),
'format' => '%s %s %s'
),
array(
'fields' => array('lastname', 'firstname'),
'format' => '%s, %s'
),
array(
'fields' => array('firstname', 'lastname'),
'format' => '%s %s'
),
)
),
'firstname' => 'given-name',
'lastname' => 'last-name',
'middlenames' => 'middle-names',
'namePrefix' => 'prefix',
'nameSuffix' => 'suffix',
'initials' => 'initials',
'nickname' => 'nick-name',
'photo' => 'photo',
'phototype' => 'phototype',
'gender' => 'gender',
'birthday' => 'birthday',
'spouse' => 'spouse-name',
'anniversary' => 'anniversary',
'children' => 'children',
/* Location */
'workStreet' => 'addr-business-street',
'workCity' => 'addr-business-locality',
'workProvince' => 'addr-business-region',
'workPostalCode' => 'addr-business-postal-code',
'workCountry' => 'addr-business-country',
'homeStreet' => 'addr-home-street',
'homeCity' => 'addr-home-locality',
'homeProvince' => 'addr-home-region',
'homePostalCode' => 'addr-home-postal-code',
'homeCountry' => 'addr-home-country',
/* Communications */
'emails' => 'emails',
'homePhone' => 'phone-home1',
'workPhone' => 'phone-business1',
'cellPhone' => 'phone-mobile',
'fax' => 'phone-businessfax',
'imaddress' => 'im-address',
/* Organization */
'title' => 'job-title',
'role' => 'profession',
'company' => 'organization',
'department' => 'department',
'office' => 'office-location',
'manager' => 'manager-name',
'assistant' => 'assistant',
/* Other */
'category' => 'categories',
'notes' => 'body',
'website' => 'web-page',
'freebusyUrl' => 'free-busy-url',
'language' => 'language',
'latitude' => 'latitude',
'longitude' => 'longitude',
/* Invisible */
'email' => 'email',
'pgpPublicKey' => 'pgp-publickey',
);
}
static private function _getSqlMap()
{
return array(
'__key' => 'object_id',
'__owner' => 'owner_id',
'__type' => 'object_type',
'__members' => 'object_members',
'__uid' => 'object_uid',
'firstname' => 'object_firstname',
'lastname' => 'object_lastname',
'middlenames' => 'object_middlenames',
'namePrefix' => 'object_nameprefix',
'nameSuffix' => 'object_namesuffix',
'name' => array('fields' => array('namePrefix', 'firstname',
'middlenames', 'lastname',
'nameSuffix'),
'format' => '%s %s %s %s %s',
'parse' => array(
array('fields' => array('firstname', 'middlenames',
'lastname'),
'format' => '%s %s %s'),
array('fields' => array('firstname', 'lastname'),
'format' => '%s %s'))),
// This is a shorter version of a "name" composite field which only
// consists of the first name and last name.
// 'name' => array('fields' => array('firstname', 'lastname'),
// 'format' => '%s %s'),
'alias' => 'object_alias',
'birthday' => 'object_bday',
'anniversary' => 'object_anniversary',
'spouse' => 'object_spouse',
'photo' => 'object_photo',
'phototype' => 'object_phototype',
'homeStreet' => 'object_homestreet',
'homePOBox' => 'object_homepob',
'homeCity' => 'object_homecity',
'homeProvince' => 'object_homeprovince',
'homePostalCode' => 'object_homepostalcode',
'homeCountry' => 'object_homecountry',
'homeAddress' => array('fields' => array('homeStreet', 'homeCity',
'homeProvince',
'homePostalCode'),
'format' => "%s \n %s, %s %s"),
'workStreet' => 'object_workstreet',
'workPOBox' => 'object_workpob',
'workCity' => 'object_workcity',
'workProvince' => 'object_workprovince',
'workPostalCode' => 'object_workpostalcode',
'workCountry' => 'object_workcountry',
'workAddress' => array('fields' => array('workStreet', 'workCity',
'workProvince',
'workPostalCode'),
'format' => "%s \n %s, %s %s"),
'department' => 'object_department',
'timezone' => 'object_tz',
'email' => 'object_email',
'homePhone' => 'object_homephone',
'homeFax' => 'object_homefax',
'workPhone' => 'object_workphone',
'cellPhone' => 'object_cellphone',
'assistPhone' => 'object_assistantphone',
'fax' => 'object_fax',
'pager' => 'object_pager',
'title' => 'object_title',
'role' => 'object_role',
'company' => 'object_company',
'logo' => 'object_logo',
'logotype' => 'object_logotype',
'category' => 'object_category',
'notes' => 'object_notes',
'website' => 'object_url',
'freebusyUrl' => 'object_freebusyurl',
'pgpPublicKey' => 'object_pgppublickey',
'smimePublicKey' => 'object_smimepublickey',
'imaddress' => 'object_imaddress',
'imaddress2' => 'object_imaddress2',
'imaddress3' => 'object_imaddress3'
);
}
}
|