handle the case that the Invoice model is missing
[tine20] / tests / tine20 / Tinebase / Frontend / JsonTest.php
1 <?php
2 /**
3  * Tine 2.0
4  *
5  * @package     Tinebase
6  * @subpackage  Json
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
8  * @author      Philipp Schüle <p.schuele@metaways.de>
9  * @copyright   Copyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)
10  *
11  */
12
13 /**
14  * Test class for Tinebase_Frontend_Json
15  */
16 class Tinebase_Frontend_JsonTest extends TestCase
17 {
18     /**
19      * unit under test (UIT)
20      * @var Tinebase_Frontend_Json
21      */
22     protected $_instance;
23
24     /**
25      * @var array test objects
26      */
27     protected $_objects = array();
28     
29     /**
30      * set up tests
31      *
32      */
33     public function setUp()
34     {
35         parent::setUp();
36         
37         $this->_instance = new Tinebase_Frontend_Json();
38         
39         $this->_objects['record'] = array(
40             'id'        => 1,
41             'model'     => 'Addressbook_Model_Contact',
42             'backend'    => 'Sql',
43         );
44
45         $this->_objects['group'] = new Tinebase_Model_Group(array(
46             'name'            => 'phpunit test group',
47             'description'    => 'phpunit test group'
48         ));
49
50         $this->_objects['role'] = new Tinebase_Model_Role(array(
51             'name'            => 'phpunit test role',
52             'description'    => 'phpunit test role'
53         ));
54
55         $this->_objects['note'] = new Tinebase_Model_Note(array(
56             'note_type_id'      => 1,
57             'note'              => 'phpunit test note',
58             'record_model'      => $this->_objects['record']['model'],
59             'record_backend'    => $this->_objects['record']['backend'],
60         ));
61     }
62     
63     /**
64      * tear down
65      */
66     public function tearDown()
67     {
68         parent::tearDown();
69         
70         // reset tz in core
71         Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, Tinebase_Core::getPreference()->getValue(Tinebase_Preference::TIMEZONE));
72     }
73     
74     /**
75      * try to add a note type
76      */
77     public function testSearchNotes()
78     {
79         $contact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_family' => 'Schulz')));
80         $note = $this->_objects['note'];
81         $note->record_id = $contact->getId();
82         Tinebase_Notes::getInstance()->addNote($note);
83
84         $filter = array(array(
85             'field' => 'query',
86             'operator' => 'contains',
87             'value' => 'phpunit'
88         ), array(
89             'field' => "record_model",
90             'operator' => "equals",
91             'value' => $this->_objects['record']['model']
92         ), array(
93             'field' => 'record_id',
94             'operator' => 'equals',
95             'value' => $contact->getId()
96         ));
97         $paging = array();
98         
99         $notes = $this->_instance->searchNotes($filter, $paging);
100         
101         $this->assertGreaterThan(0, $notes['totalcount']);
102         $found = false;
103         foreach ($notes['results'] as $note) {
104             if ($this->_objects['note']->note === $note['note']) {
105                 $found = true;
106             }
107         }
108         $this->assertTrue($found, 'note not found in notes: ' . print_r($notes['results'], true));
109         
110         // delete note
111         Tinebase_Notes::getInstance()->deleteNotesOfRecord(
112             $this->_objects['record']['model'],
113             $this->_objects['record']['backend'],
114             $contact->getId()
115         );
116     }
117     
118     /**
119      * try to delete role and then search
120      */
121     public function testSearchRoles()
122     {
123         $role = Tinebase_Acl_Roles::getInstance()->createRole($this->_objects['role']);
124         
125         $filter = array(array(
126             'field'     => 'query',
127             'operator'     => 'contains',
128             'value'     => 'phpunit test role'
129         ));
130         $paging = array(
131             'start'    => 0,
132             'limit'    => 1
133         );
134         
135         $roles = $this->_instance->searchRoles($filter, $paging);
136         
137         $this->assertGreaterThan(0, $roles['totalcount']);
138         $this->assertEquals($this->_objects['role']->name, $roles['results'][0]['name']);
139         
140         // delete role
141         Tinebase_Acl_Roles::getInstance()->deleteRoles($role->id);
142     }
143     
144     /**
145      * test getCountryList
146      *
147      */
148     public function testGetCountryList()
149     {
150         $list = $this->_instance->getCountryList();
151         $this->assertTrue(count($list['results']) > 200);
152     }
153     
154     /**
155      * test get translations
156      *
157      */
158     public function testGetAvailableTranslations()
159     {
160         $list = $this->_instance->getAvailableTranslations();
161         $this->assertTrue(count($list['results']) > 3);
162     }
163     
164     /**
165      * tests locale fallback
166      */
167     public function testSetLocaleFallback()
168     {
169         // de_LU -> de
170         $this->_instance->setLocale('de_LU', FALSE, FALSE);
171         $this->assertEquals('de', (string)Zend_Registry::get('locale'), 'Fallback to generic german did not succseed');
172         
173         $this->_instance->setLocale('zh', FALSE, FALSE);
174         $this->assertEquals('zh_CN', (string)Zend_Registry::get('locale'), 'Fallback to simplified chinese did not succseed');
175         
176         $this->_instance->setLocale('foo_bar', FALSE, FALSE);
177         $this->assertEquals('en', (string)Zend_Registry::get('locale'), 'Exception fallback to english did not succseed');
178     }
179     
180     /**
181      * test set locale and save it in db
182      */
183     public function testSetLocaleAsPreference()
184     {
185         $oldPreference = Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE};
186         
187         $locale = 'de';
188         $result = $this->_instance->setLocale($locale, TRUE, FALSE);
189         
190         // get config setting from db
191         $preference = Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE};
192         $this->assertEquals($locale, $preference, "Didn't get right locale preference.");
193         
194         // restore old setting
195         Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE} = $oldPreference;
196     }
197
198     /**
199      * test set timezone and save it in db
200      */
201     public function testSetTimezoneAsPreference()
202     {
203         $oldPreference = Tinebase_Core::getPreference()->{Tinebase_Preference::TIMEZONE};
204         
205         $timezone = 'America/Vancouver';
206         $result = $this->_instance->setTimezone($timezone, true);
207         
208         // check json result
209         $this->assertEquals($timezone, $result);
210         
211         // get config setting from db
212         $preference = Tinebase_Core::getPreference()->{Tinebase_Preference::TIMEZONE};
213         $this->assertEquals($timezone, $preference, "Didn't get right timezone preference.");
214         
215         // restore old settings
216         Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, $oldPreference);
217         Tinebase_Core::getPreference()->{Tinebase_Preference::TIMEZONE} = $oldPreference;
218     }
219     
220     /**
221      * get notes types
222      */
223     public function testGetNotesTypes()
224     {
225         $noteTypes = $this->_instance->getNoteTypes();
226         $this->assertTrue($noteTypes['totalcount'] >= 5);
227     }
228     
229     /**
230      * search preferences by application
231      *
232      */
233     public function testSearchPreferences()
234     {
235         // search prefs
236         $result = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter());
237         
238         // check results
239         $this->assertTrue(isset($result['results']));
240         $this->assertGreaterThan(2, $result['totalcount']);
241         
242         //check locale/timezones options
243         foreach ($result['results'] as $pref) {
244             switch($pref['name']) {
245                 case Tinebase_Preference::LOCALE:
246                     $this->assertGreaterThan(10, count($pref['options']));
247                     break;
248                 case Tinebase_Preference::TIMEZONE:
249                     $this->assertGreaterThan(100, count($pref['options']));
250                     break;
251             }
252             // check label and description
253             $this->assertTrue(isset($pref['label']) && !empty($pref['label']));
254             $this->assertTrue(isset($pref['description']) && !empty($pref['description']));
255         }
256     }
257
258     /**
259      * search preferences by application
260      *
261      */
262     public function testSearchPreferencesWithOptions()
263     {
264         // add new default pref
265         $pref = $this->_getPreferenceWithOptions();
266         $pref = Tinebase_Core::getPreference()->create($pref);
267         
268         // search prefs
269         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter());
270         
271         // check results
272         $this->assertTrue(isset($results['results']));
273         $this->assertGreaterThan(3, $results['totalcount']);
274         
275         foreach ($results['results'] as $result) {
276             if ($result['name'] == 'defaultapp') {
277                 $this->assertEquals(Tinebase_Model_Preference::DEFAULT_VALUE, $result['value']);
278                 $this->assertTrue(is_array($result['options']));
279                 $this->assertEquals(3, count($result['options']));
280                 $this->assertContains('option1', $result['options'][1][1]);
281             } else if ($result['name'] == Tinebase_Preference::TIMEZONE) {
282                 $this->assertTrue(is_array($result['options'][0]), 'options should be arrays');
283             }
284         }
285         
286         Tinebase_Core::getPreference()->delete($pref);
287     }
288     
289     /**
290      * search preferences of another user
291      *
292      * @todo add check for the case that searching user has no admin rights
293      */
294     public function testSearchPreferencesOfOtherUsers()
295     {
296         // add new default pref
297         $pref = $this->_getPreferenceWithOptions();
298         $pref->account_id   = '2';
299         $pref->account_type = Tinebase_Acl_Rights::ACCOUNT_TYPE_USER;
300         $pref = Tinebase_Core::getPreference()->create($pref);
301         
302         // search prefs
303         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter(TRUE, FALSE, '2'));
304         
305         // check results
306         $this->assertTrue(isset($results['results']));
307         $this->assertEquals(1, $results['totalcount']);
308     }
309     
310     /**
311      * save preferences for user
312      *
313      * @todo add test for saving of other users prefs and acl check
314      */
315     public function testSavePreferences()
316     {
317         $prefData = $this->_getUserPreferenceData();
318         $this->_instance->savePreferences($prefData, false);
319
320         // search saved prefs
321         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter(FALSE));
322         
323         // check results
324         $this->assertTrue(isset($results['results']));
325         $this->assertGreaterThan(2, $results['totalcount']);
326         
327         $savedPrefData = array();
328         foreach ($results['results'] as $result) {
329             if ($result['name'] == 'timezone') {
330                 $savedPrefData['Tinebase'][$result['name']] = array('value' => $result['value']);
331             
332                 $this->assertTrue(is_array($result['options']), 'options missing');
333                 $this->assertGreaterThan(100, count($result['options']));
334             }
335         }
336         $this->assertEquals($prefData, $savedPrefData);
337     }
338     
339     /**
340      * tests if 'use default' appears in options and if it can be selected and if it changes if default changes
341      */
342     public function testGetSetChangeDefaultPref()
343     {
344         $locale = $this->_getLocalePref();
345         foreach ($locale['options'] as $option) {
346             if ($option[0] == Tinebase_Model_Preference::DEFAULT_VALUE) {
347                 $result = $option;
348                 $defaultString = $option[1];
349             }
350         }
351         
352         $this->assertTrue(isset($defaultString));
353         $this->assertContains('(auto)', $defaultString);
354
355         // set user pref to en first then to 'use default'
356         Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE} = 'en';
357         Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE} = Tinebase_Model_Preference::DEFAULT_VALUE;
358         $this->assertEquals('auto', Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE});
359         
360         // set new default locale
361         $prefData['Tinebase']['default' . $locale['id']] = array('value' => 'de', 'type' => 'default', 'name' => Tinebase_Preference::LOCALE);
362         $this->_instance->savePreferences($prefData, true);
363         
364         $updatedLocale = $this->_getLocalePref();
365         foreach ($updatedLocale['options'] as $option) {
366             if ($option[0] == Tinebase_Model_Preference::DEFAULT_VALUE) {
367                 $result = $option;
368                 $defaultString = $option[1];
369             }
370         }
371         $this->assertEquals(count($locale['options']), count($updatedLocale['options']), 'option count has to be equal');
372         $this->assertContains('(Deutsch)', $defaultString);
373         $this->assertEquals('de', Tinebase_Core::getPreference()->{Tinebase_Preference::LOCALE});
374     }
375     
376     /**
377      * get locale pref
378      */
379     protected function _getLocalePref()
380     {
381         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter());
382         foreach ($results['results'] as $result) {
383             if ($result['name'] == Tinebase_Preference::LOCALE) {
384                 $locale = $result;
385             }
386         }
387         
388         $this->assertTrue(isset($locale));
389         
390         return $locale;
391     }
392
393     /**
394      * get admin prefs
395      */
396     public function testGetAdminPreferences()
397     {
398         $this->testGetSetChangeDefaultPref();
399         
400         // set new default locale
401         $locale = $this->_getLocalePref();
402         $prefData['Tinebase'][$locale['id']] = array('value' => 'de', 'type' => 'default', 'name' => Tinebase_Preference::LOCALE);
403         $this->_instance->savePreferences($prefData, true);
404         
405         // check as admin
406         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter(FALSE, TRUE));
407         foreach ($results['results'] as $pref) {
408             if ($pref['name'] !== Tinebase_Preference::LOCALE) {
409                 $this->assertEquals(Tinebase_Model_Preference::DEFAULT_VALUE, $pref['value']);
410             } else {
411                 $this->assertEquals(Tinebase_Model_Preference::TYPE_ADMIN, $pref['type']);
412                 $this->assertEquals('de', $pref['value'], print_r($pref, TRUE));
413             }
414         }
415
416         // check as user
417         $locale = $this->_getLocalePref();
418         $this->assertEquals(Tinebase_Model_Preference::TYPE_ADMIN, $locale['type'], 'pref should be of type admin: ' . print_r($locale, TRUE));
419         $this->assertEquals(Tinebase_Model_Preference::DEFAULT_VALUE, $locale['value'], 'pref should be default value: ' . print_r($locale, TRUE));
420     }
421     
422     /**
423      * save admin prefs
424      *
425      */
426     public function testSaveAdminPreferences()
427     {
428         // add new default pref
429         $pref = $this->_getPreferenceWithOptions();
430         $pref = Tinebase_Core::getPreference()->create($pref);
431         
432         $prefData = array();
433         $prefData['Tinebase'][$pref->getId()] = array('value' => 'test', 'type' => 'forced');
434         $this->_instance->savePreferences($prefData, true);
435
436         // search saved prefs
437         $results = $this->_instance->searchPreferencesForApplication('Tinebase', $this->_getPreferenceFilter(TRUE));
438         
439         // check results
440         $this->assertTrue(isset($results['results']));
441         $this->assertEquals(1, $results['totalcount']);
442         $this->assertEquals($prefData['Tinebase'][$pref->getId()]['value'], $results['results'][0]['value']);
443         $this->assertEquals($prefData['Tinebase'][$pref->getId()]['type'], $results['results'][0]['type']);
444     }
445     
446     /**
447      * save state and load it with registry data
448      */
449     public function testSaveAndGetState()
450     {
451         $testData = array(
452             'bla'   => 'blubb',
453             'zzing' => 'zzang'
454         );
455         
456         foreach ($testData as $key => $value) {
457             Tinebase_State::getInstance()->setState($key, $value);
458         }
459         
460         $stateInfo = Tinebase_State::getInstance()->loadStateInfo();
461         
462         $this->assertEquals($testData, $stateInfo);
463     }
464     
465     /**
466      * test get all registry data
467      *
468      * @return void
469      *
470      * @see 0007934: change pw button active even if it is not allowed
471      * @see 0008310: apps should be sorted the other way round in menu
472      * @see 0009130: Can't open login page on Ubuntu "due to a temporary overloading"
473      */
474     public function testGetAllRegistryData()
475     {
476         $registryData = $this->_instance->getAllRegistryData();
477         $currentUser = Tinebase_Core::getUser();
478         
479         $this->assertEquals($currentUser->toArray(), $registryData['Tinebase']['currentAccount']);
480         $this->assertEquals(
481             Addressbook_Controller_Contact::getInstance()->getContactByUserId($currentUser->getId())->toArray(),
482             $registryData['Tinebase']['userContact']
483         );
484         $this->assertEquals(TRUE, $registryData['Tinebase']['config']['changepw']['value'], 'changepw should be TRUE');
485         
486         Tinebase_Config::getInstance()->set('changepw', 0);
487         $registryData = $this->_instance->getAllRegistryData();
488         $changepwValue = $registryData['Tinebase']['config']['changepw']['value'];
489         $this->assertEquals(FALSE, $changepwValue, 'changepw should be (bool) false');
490         $this->assertTrue(is_bool($changepwValue), 'changepw should be (bool) false: ' . var_export($changepwValue, TRUE));
491         
492         $userApps = $registryData['Tinebase']['userApplications'];
493         $this->assertEquals('Admin', $userApps[0]['name'], 'first app should be Admin: ' . print_r($userApps, TRUE));
494         
495         $locale = Tinebase_Core::getLocale();
496         $symbols = Zend_Locale::getTranslationList('symbols', $locale);
497         $this->assertEquals($symbols['decimal'], $registryData['Tinebase']['decimalSeparator']);
498     }
499
500     /**
501      * test get all registry data with persistent filters
502      * 
503      * @return void
504      * 
505      * @see 0009610: shared favorites acl
506      */
507     public function testGetAllPersistentFilters()
508     {
509         $this->markTestSkipped('@see 0010192: fix persistent filter tests');
510         
511         $registryData = $this->_instance->getAllRegistryData();
512         
513         $filterData = $registryData['Tinebase']['persistentFilters'];
514         $this->assertTrue($filterData['totalcount'] > 10);
515         $this->assertTrue(isset($filterData['results'][0]['grants']), 'grants are missing');
516         $grants = $filterData['results'][0]['grants'];
517         $this->assertTrue($grants[0]['readGrant']);
518         
519         // check if accounts are resolved
520         $this->assertTrue(is_array($grants[0]['account_name']), 'account should be resolved: ' . print_r($grants[0], true));
521     }
522     
523     /**
524      * testGetUserProfile
525      */
526     public function testGetUserProfile()
527     {
528         $profile = $this->_instance->getUserProfile(Tinebase_Core::getUser()->getId());
529
530         $this->assertTrue(is_array($profile));
531         $this->assertTrue((isset($profile['userProfile']) || array_key_exists('userProfile', $profile)));
532         $this->assertTrue(is_array($profile['userProfile']));
533         $this->assertTrue((isset($profile['readableFields']) || array_key_exists('readableFields', $profile)));
534         $this->assertTrue(is_array($profile['readableFields']));
535         $this->assertTrue((isset($profile['updateableFields']) || array_key_exists('updateableFields', $profile)));
536         $this->assertTrue(is_array($profile['updateableFields']));
537         
538         // try to get user profile of different user
539         $this->setExpectedException('Tinebase_Exception_AccessDenied');
540         
541         $sclever = Tinebase_Helper::array_value('sclever',Zend_Registry::get('personas'));
542         $this->_instance->getUserProfile($sclever->getId());
543     }
544     
545     /**
546      * testGetUserProfileConfig
547      */
548     public function testGetUserProfileConfig()
549     {
550         $config = $this->_instance->getUserProfileConfig();
551         
552         $this->assertTrue(is_array($config));
553         $this->assertTrue((isset($config['possibleFields']) || array_key_exists('possibleFields', $config)));
554         $this->assertTrue(is_array($config['possibleFields']));
555         $this->assertTrue((isset($config['readableFields']) || array_key_exists('readableFields', $config)));
556         $this->assertTrue(is_array($config['readableFields']));
557         $this->assertTrue((isset($config['updateableFields']) || array_key_exists('updateableFields', $config)));
558         $this->assertTrue(is_array($config['updateableFields']));
559     }
560     
561     /**
562      * testSetUserProfileConfig
563      */
564     public function testSetUserProfileConfig()
565     {
566         $config = $this->_instance->getUserProfileConfig();
567         
568         $idx = array_search('n_prefix', $config['readableFields']);
569         if ($idx !== false) {
570             unset ($config['readableFields'][$idx]);
571         }
572         
573         $idx = array_search('tel_home', $config['updateableFields']);
574         if ($idx !== false) {
575             unset ($config['updateableFields'][$idx]);
576         }
577         
578         $this->_instance->setUserProfileConfig($config);
579     }
580     
581     /**
582      * testupdateUserProfile
583      */
584     public function testUpdateUserProfile()
585     {
586         $profile = $this->_instance->getUserProfile(Tinebase_Core::getUser()->getId());
587         $profileData = $profile['userProfile'];
588         
589         $this->assertFalse(array_search('n_prefix', $profileData));
590         
591         $profileData['tel_home'] = 'mustnotchange';
592         $profileData['email_home'] = 'email@userprofile.set';
593         
594         $this->_instance->updateUserProfile($profileData);
595         
596         $updatedProfile = $this->_instance->getUserProfile(Tinebase_Core::getUser()->getId());
597         $updatedProfileData = $updatedProfile['userProfile'];
598         $this->assertNotEquals('mustnotchange', $updatedProfileData['tel_home']);
599         $this->assertEquals('email@userprofile.set', $updatedProfileData['email_home']);
600     }
601     
602     /**
603      * testGetSaveApplicationConfig
604      */
605     public function testGetSaveApplicationConfig()
606     {
607         $config = $this->_instance->getConfig('Admin');
608         $this->assertGreaterThan(0, count($config));
609         
610         $data = array(
611             'id'        => 'Admin',
612             'settings'  => Admin_Controller::getInstance()->getConfigSettings(),
613         );
614         
615         $newConfig = $this->_instance->saveConfig($data);
616         
617         $this->assertEquals($config, $newConfig);
618     }
619     
620     /**
621      * testChangeUserAccount
622      * 
623      * @see 0009984: allow to change user role
624      */
625     public function testChangeUserAccount()
626     {
627         // allow test user to sign in as sclever
628         Tinebase_Config::getInstance()->set(Tinebase_Config::ROLE_CHANGE_ALLOWED, new Tinebase_Config_Struct(array(
629             Tinebase_Core::getUser()->accountLoginName => array('sclever')
630         )));
631         
632         $sclever = $this->_personas['sclever'];
633         $result = $this->_instance->changeUserAccount('sclever');
634         
635         $this->assertEquals(array('success' => true), $result);
636         
637         // make sure, we are sclever
638         $this->assertEquals('sclever', Tinebase_Core::getUser()->accountLoginName);
639         $this->assertEquals('sclever', Tinebase_Session::getSessionNamespace()->currentAccount->accountLoginName);
640         
641         Tinebase_Controller::getInstance()->initUser($this->_originalTestUser, /* $fixCookieHeader = */ false);
642     }
643     
644     /******************** protected helper funcs ************************/
645     
646     /**
647      * get preference filter
648      *
649      * @param bool $_savedPrefs
650      * @return array
651      */
652     protected function _getPreferenceFilter($_savedPrefs = FALSE, $_adminPrefs = FALSE, $_userId = NULL)
653     {
654         if ($_userId === NULL) {
655             $_userId = Tinebase_Core::getUser()->getId();
656         }
657         
658         $result = array(
659             array(
660                 'field' => 'account',
661                 'operator' => 'equals',
662                 'value' => array(
663                     'accountId'     => ($_adminPrefs) ? 0 : $_userId,
664                     'accountType'   => ($_adminPrefs)
665                         ? Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE
666                         : Tinebase_Acl_Rights::ACCOUNT_TYPE_USER
667                 )
668             )
669         );
670
671         if ($_savedPrefs) {
672             $result[] = array(
673                 'field' => 'name',
674                 'operator' => 'contains',
675                 'value' => 'defaultapp'
676             );
677         }
678         
679         return $result;
680     }
681
682     /**
683      * get preference data for testSavePreferences()
684      *
685      * @return array
686      */
687     protected function _getUserPreferenceData()
688     {
689         return array(
690             'Tinebase' => array(
691                 'timezone' => array('value' => 'Europe/Amsterdam'),
692             )
693         );
694     }
695     
696     /**
697      * get preference with options
698      *
699      * @return Tinebase_Model_Preference
700      */
701     protected function _getPreferenceWithOptions()
702     {
703         return new Tinebase_Model_Preference(array(
704             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId(),
705             'name'              => 'defaultapp',
706             'value'             => 'value1',
707             'account_id'        => '0',
708             'account_type'      => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE,
709             'type'              => Tinebase_Model_Preference::TYPE_ADMIN,
710             'options'           => '<?xml version="1.0" encoding="UTF-8"?>
711                 <options>
712                     <option>
713                         <label>option1</label>
714                         <value>value1</value>
715                     </option>
716                     <option>
717                         <label>option2</label>
718                         <value>value2</value>
719                     </option>
720                 </options>'
721         ));
722     }
723 }