public function testSearchEvents()
 {
     $allUsers = Tinebase_User::getInstance()->getFullUsers('');
     xhprof_enable();
     $numSearches = 0;
     foreach ($allUsers as $user) {
         if ($numSearches > 5) {
             break;
         }
         echo "getting month view for {$user->accountDisplayName}\n";
         $filterData = array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('/personal/' . $user->getId(), '/shared')), array('field' => 'period', 'operator' => 'within', 'value' => array('from' => '2010-03-01 00:00:00', 'until' => '2010-04-01 00:00:00')));
         //            $filter = new Calendar_Model_EventFilter($filterData);
         //            $events = Calendar_Controller_Event::getInstance()->search($filter, NULL, FALSE);
         $this->_json->searchEvents($filterData, NULL);
         $numSearches += 1;
     }
     $xhprof_data = xhprof_disable();
     //Tinebase_Core::getDbProfiling();
     $XHPROF_ROOT = '/opt/local/www/php5-xhprof';
     include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
     include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
     $xhprof_runs = new XHProfRuns_Default();
     $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_tine20");
     echo "http://localhost/xhprof_html/index.php?run={$run_id}&source=xhprof_tine20 \n";
     print_r(Tinebase_Record_Abstract::$cns);
 }
 /**
  * testRenameResource
  * 
  * @see 0010106: rename resource does not update container name
  */
 public function testRenameResource()
 {
     $resource = $this->_getResource();
     $createResource = Calendar_Controller_Resource::getInstance()->create($resource);
     $calenderFrontend = new Calendar_Frontend_Json();
     $resourceArrayFromDB = $calenderFrontend->getResource($createResource->getId());
     $resourceArrayFromDB['name'] = 'Other Room';
     $calenderFrontend->saveResource($resourceArrayFromDB);
     $containerFrontend = new Tinebase_Frontend_Json_Container();
     $result = $containerFrontend->getContainer('Calendar', Tinebase_Model_Container::TYPE_SHARED, '');
     foreach ($result as $container) {
         if ($container['id'] != $createResource->container_id) {
             continue;
         }
         $this->assertEquals($container['name'], 'Other Room');
     }
 }
Exemplo n.º 3
0
 /**
  * testMeAsAttenderFilter
  */
 public function testMeAsAttenderFilter()
 {
     $eventData = $this->testCreateEvent();
     $filter = array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId()), array('field' => 'attender', 'operator' => 'equals', 'value' => array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => Addressbook_Model_Contact::CURRENTCONTACT)));
     $searchResultData = $this->_uit->searchEvents($filter, array());
     $resultEventData = $searchResultData['results'][0];
     $this->_assertJsonEvent($eventData, $resultEventData, 'failed to filter for me as attender');
 }
 /**
  * testGetRelations
  * 
  * @see 0009542: load event relations on demand
  */
 public function testGetRelations()
 {
     $contact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_family' => 'Contact for relations test')));
     $eventData = $this->_getEvent()->toArray();
     $eventData['relations'] = array(array('own_model' => 'Calendar_Model_Event', 'own_backend' => 'Sql', 'own_id' => 0, 'related_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'type' => '', 'related_backend' => 'Sql', 'related_id' => $contact->getId(), 'related_model' => 'Addressbook_Model_Contact', 'remark' => NULL));
     $event = $this->_uit->saveEvent($eventData);
     $tfj = new Tinebase_Frontend_Json();
     $relations = $tfj->getRelations('Calendar_Model_Event', $event['id']);
     $this->assertEquals(1, $relations['totalcount']);
     $this->assertEquals($contact->n_fn, $relations['results'][0]['related_record']['n_family'], print_r($relations['results'], true));
 }
 /**
  * assert private event
  * 
  * @param string $searchMethod
  * @throws InvalidArgumentException
  */
 protected function _assertPrivateEvent($searchMethod = 'search')
 {
     $persistentEvent = $this->_createEventInPersonasCalendar('pwulf', 'pwulf', 'pwulf', Calendar_Model_Event::CLASS_PRIVATE);
     if ($searchMethod === 'search') {
         $filterData = array(array('field' => 'id', 'operator' => 'equals', 'value' => $persistentEvent->getId()));
         $events = $this->_uit->search(new Calendar_Model_EventFilter($filterData), NULL, FALSE, FALSE);
         // assert json fe does not add history
         $json = new Calendar_Frontend_Json();
         $resolvedEvents = $json->searchEvents($filterData, array());
         $this->assertTrue(empty($resolvedEvents['results'][0]['notes']));
     } else {
         if ($searchMethod === 'getMultiple') {
             $events = $this->_uit->getMultiple(array($persistentEvent->getId()));
         } else {
             throw new InvalidArgumentException('unknown search method: ' . $searchMethod);
         }
     }
     $this->assertTrue($events[0]->summary == '');
 }
 /**
  * search an private event of pwulf
  *  -> test user has no private grant -> must be freebusy cleaned!
  */
 public function testPrivateCleanup()
 {
     $persistentEvent = $this->_createEventInPersonasCalendar('pwulf', 'pwulf', 'pwulf', Calendar_Model_Event::CLASS_PRIVATE);
     $filterData = array(array('field' => 'id', 'operator' => 'equals', 'value' => $persistentEvent->getId()));
     $events = $this->_uit->search(new Calendar_Model_EventFilter($filterData), NULL, FALSE, FALSE);
     $this->assertTrue($events[0]->summary == '');
     // assert json fe does not add history
     $json = new Calendar_Frontend_Json();
     $resolvedEvents = $json->searchEvents($filterData, array());
     $this->assertTrue(empty($resolvedEvents['results'][0]['notes']));
 }