/**
  * try to delete a contact and its id
  *
  */
 public function testDeleteContact()
 {
     $contact = $this->testCreateContact();
     $this->_backend->delete($contact->getId());
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_backend->get($contact->getId());
 }
 /**
  * test create container
  */
 public function testCreateContainerAndDeleteContents()
 {
     $container = $this->_json->saveContainer(array("type" => Tinebase_Model_Container::TYPE_SHARED, "backend" => "Sql", "name" => "asdfgsadfg", "color" => "#008080", "application_id" => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), "model" => "", "note" => ""));
     // check if the model was set
     $this->assertEquals($container['model'], 'Addressbook_Model_Contact');
     $contact = new Addressbook_Model_Contact(array('n_given' => 'max', 'n_family' => 'musterman', 'container_id' => $container['id']));
     $contact = Addressbook_Controller_Contact::getInstance()->create($contact);
     $this->_json->deleteContainers(array($container['id']));
     $cb = new Addressbook_Backend_Sql();
     $del = $cb->get($contact->getId(), true);
     // record should be deleted
     $this->assertEquals($del->is_deleted, 1);
     try {
         Addressbook_Controller_Contact::getInstance()->get($contact->getId(), $container['id']);
         $this->fail('The expected exception was not thrown');
     } catch (Tinebase_Exception_NotFound $e) {
         // ok;
     }
     // record should not be found
     $this->assertEquals($e->getMessage(), 'Addressbook_Model_Contact record with id = ' . $contact->getId() . ' not found!');
 }
 /**
  * test if deleted users data is removed
  *
  * @see TODO add mantis issue
  *
  * TODO add test cases for keepOrganizerEvents and $_keepAsContact and $_keepAsContact
  */
 public function testDeleteUsersData()
 {
     // configure removal of data
     Tinebase_Config::getInstance()->set(Tinebase_Config::ACCOUNT_DELETION_EVENTCONFIGURATION, new Tinebase_Config_Struct(array('_deletePersonalContainers' => true)));
     // we need a valid group and a contact for this test
     $userContact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_given' => 'testuser')));
     $testUser = $this->getTestRecord();
     $testUser->contact_id = $userContact->getId();
     $this->_backend->addUser($testUser);
     Tinebase_Group::getInstance()->addGroupMember($testUser->accountPrimaryGroup, $testUser->getId());
     $this->_setUser($testUser);
     // add a contact and an event to personal folders
     $event = Calendar_Controller_Event::getInstance()->create(new Calendar_Model_Event(array('summary' => 'testevent', 'dtstart' => '2015-12-24 12:00:00', 'dtend' => '2015-12-24 13:00:00'), true));
     $contact = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_given' => 'testcontact')));
     $this->_setUser($this->_originalTestUser);
     $this->_backend->deleteUser($testUser);
     // check if contact and event are removed
     $adbBackend = new Addressbook_Backend_Sql();
     try {
         $adbBackend->get($contact->getId());
         $this->fail('contact be deleted');
     } catch (Exception $e) {
         $this->assertTrue($e instanceof Tinebase_Exception_NotFound);
     }
     $calBackend = new Calendar_Backend_Sql();
     try {
         $calBackend->get($event->getId());
         $this->fail('event should be deleted: ' . print_r($event->toArray(), true));
     } catch (Exception $e) {
         $this->assertTrue($e instanceof Tinebase_Exception_NotFound);
     }
 }
示例#4
0
 /**
  * try to delete a contact
  *
  */
 public function testDeleteContact()
 {
     $this->_backend->delete($GLOBALS['Addressbook_ControllerTest']['contactId']);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_backend->get($GLOBALS['Addressbook_ControllerTest']['contactId']);
 }