/** * try to add an account * */ public function testAddUser() { $testUser = $this->getTestRecord(); $testUser->setId(Tinebase_Record_Abstract::generateUID()); $this->objects['users']['addedUser'] = $this->_backend->addUser($testUser); $this->assertEquals($testUser->getId(), $this->objects['users']['addedUser']->getId()); $this->assertEquals('hidden', $this->objects['users']['addedUser']->visibility); $this->assertEquals('Tinebase_Model_FullUser', get_class($testUser), 'wrong type'); return $this->objects['users']['addedUser']; }
/** * 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); } }