Merge branch '2015.11-develop' into 2016.11
[tine20] / tests / tine20 / Calendar / Setup / DemoDataTests.php
1 <?php
2 /**
3  * Tine 2.0 - http://www.tine20.org
4  * 
5  * @package     Calendar
6  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
7  * @copyright   Copyright (c) 2012 Metaways Infosystems GmbH (http://www.metaways.de)
8  * @author      Alexander Stintzing <a.stintzing@metaways.de>
9  */
10 require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
11
12 /**
13  * Test class for Setup DemoData
14  * 
15  * @package     Calendar
16  */
17 class Calendar_Setup_DemoDataTests extends TestCase
18 {
19     public function testCreateDemoCalendars()
20     {
21         ob_start();
22         Calendar_Setup_DemoData::getInstance()->createDemoData(array('locale' => 'en'));
23         ob_end_clean();
24         
25         $pwulf = Tinebase_User::getInstance()->getFullUserByLoginName('pwulf');
26         
27         $businessCalendar = Tinebase_Container::getInstance()->getContainerByName(
28             'Calendar', 'Business', Tinebase_Model_Container::TYPE_PERSONAL, $pwulf->getId());
29         $sharedCalendar = Tinebase_Container::getInstance()->getContainerByName(
30             'Calendar', 'Shared Calendar', Tinebase_Model_Container::TYPE_SHARED);
31         $cce = Calendar_Controller_Event::getInstance();
32         $filter = new Calendar_Model_EventFilter(array(
33             array('field' => 'container_id', 'operator' => 'equals', 'value' => $businessCalendar->getId())
34         ),'AND');
35         $businessEvents = $cce->search($filter);
36         $cce->deleteByFilter($filter);
37         
38         $filter = new Calendar_Model_EventFilter(array(
39             array('field' => 'container_id', 'operator' => 'equals', 'value' => $sharedCalendar->getId())
40         ),'AND');
41         $sharedEvents = $cce->search($filter);
42         $cce->deleteByFilter($filter);
43         
44         $this->assertEquals($businessEvents->count(), 1);
45         $this->assertEquals($sharedEvents->count(), 10);
46     }
47 }