/**
  * test deleting contact
  *
  */
 public function testDeleteContact()
 {
     $contact = $this->_addContact();
     $this->_uit->deleteContacts($contact['id']);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_uit->getContact($contact['id']);
 }
 /**
  * test searching records by date as a customfield type
  * https://forge.tine20.org/mantisbt/view.php?id=6730
  */
 public function testSearchByDate()
 {
     $date = new Tinebase_DateTime();
     $cf = self::getCustomField(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_Contact', 'definition' => array('type' => 'date')));
     $this->_instance->addCustomField($cf);
     $contact = new Addressbook_Model_Contact(array('n_given' => 'Rita', 'n_family' => 'Blütenrein'));
     $contact->customfields = array($cf->name => $date);
     $contact = Addressbook_Controller_Contact::getInstance()->create($contact, false);
     $json = new Addressbook_Frontend_Json();
     $filter = array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "within", "value" => array("cfId" => $cf->getId(), "value" => "weekThis"))))));
     $result = $json->searchContacts(array($filter), array());
     $this->assertEquals(1, $result['totalcount'], 'searched contact not found. filter: ' . print_r($filter, true));
     $this->assertEquals('Rita', $result['results'][0]['n_given']);
     $json->deleteContacts(array($contact->getId()));
     $this->_instance->deleteCustomField($cf);
 }