Пример #1
0
 /**
  * test deleting contact
  *
  */
 public function testDeleteContact()
 {
     $contact = $this->_addContact();
     $this->_instance->deleteContacts($contact['id']);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_instance->getContact($contact['id']);
 }
 /**
  * helper for import with tags and keep/discard strategy
  * 
  * @param string $resolveStrategy
  * @return array
  */
 protected function _tagImportHelper($resolveStrategy)
 {
     $result = $this->_importHelper(array('dryrun' => 0));
     $klaus = $result['results'][0];
     $currentTag = $klaus['tags'][0];
     $klausId = $klaus['id'];
     if ($resolveStrategy === 'keep') {
         unset($klaus['id']);
     }
     // keep existing record and discard mine + add new tag
     $clientRecords = array(array('recordData' => $klaus, 'resolveStrategy' => $resolveStrategy, 'index' => 0));
     $tag = $this->_getTag(Tinebase_Model_Tag::TYPE_PERSONAL);
     $options = array('dryrun' => 0, 'autotags' => array($tag->toArray()));
     $result = $this->_importHelper($options, $clientRecords);
     $expectedTotalcount = $resolveStrategy === 'keep' ? 1 : 0;
     $this->assertEquals($expectedTotalcount, $result['totalcount'], 'Should discard fritz');
     $this->assertEquals(1, $result['duplicatecount'], 'fritz should still be a duplicate');
     $klaus = $this->_uit->getContact($klausId);
     return $klaus;
 }
 /**
  * testSetRelationToFileInPersonalFolder
  * 
  * @see 0006736: Create File (Edit)InfoDialog
  */
 public function testSetRelationToFileInPersonalFolder()
 {
     $node = $this->testCreateFileNodeWithUTF8Filenames();
     $node['relations'] = array($this->_getRelationData($node));
     $node = $this->_json->saveNode($node);
     $adbJson = new Addressbook_Frontend_Json();
     $contact = $adbJson->getContact($node['relations'][0]['related_id']);
     $this->assertEquals(1, count($contact['relations']));
     $relatedNode = $contact['relations'][0]['related_record'];
     $this->assertEquals($node['name'], $relatedNode['name']);
     $pathRegEx = '@^/personal/[a-f0-9-]+/[0-9]+/' . preg_quote($relatedNode['name']) . '$@';
     $this->assertTrue(preg_match($pathRegEx, $relatedNode['path']) === 1, 'path mismatch: ' . print_r($relatedNode, TRUE) . ' regex: ' . $pathRegEx);
 }
 /**
  * on saving 
  */
 public function testUpdateTimeaccountWithRelatedContact()
 {
     $this->_getTimeaccount(array(), TRUE);
     $ta = $this->_lastCreatedRecord;
     $contactController = Addressbook_Controller_Contact::getInstance();
     $taController = Timetracker_Controller_Timeaccount::getInstance();
     $bday = new Tinebase_DateTime();
     $bday->setDate(2013, 12, 24);
     $bday->setTime(0, 0, 0);
     $contact = $contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Test', 'n_family' => 'Unit', 'bday' => $bday)));
     $bday = $contact['bday'];
     Tinebase_Relations::getInstance()->setRelations('Timetracker_Model_Timeaccount', 'Sql', $ta['id'], array(array('related_backend' => 'Sql', 'type' => 'RESPONSIBLE', 'related_model' => 'Addressbook_Model_Contact', 'related_id' => $contact->getId(), 'own_degree' => 'sibling')));
     // update a few times, bday of contract should not change
     $tajson = $this->_json->getTimeaccount($ta['id']);
     $this->_json->saveTimeaccount($tajson);
     $tajson = $this->_json->getTimeaccount($ta['id']);
     $this->_json->saveTimeaccount($tajson);
     $tajson = $this->_json->getTimeaccount($ta['id']);
     $ajson = new Addressbook_Frontend_Json();
     $contactJson = $ajson->getContact($contact->getId());
     $this->assertEquals($bday->setTimezone(Tinebase_Core::getUserTimezone())->toString(), $contactJson['bday']);
 }