/** * test saveUpdateDeleteContainer */ public function testSaveUpdateDeleteContainer() { $container = $this->_saveContainer(); $this->assertEquals(Tinebase_Core::getUser()->getId(), $container['created_by']); // update container $container['name'] = 'testcontainerupdated'; $container['account_grants'] = $this->_getContainerGrants(); $containerUpdated = $this->_json->saveContainer($container); $this->assertEquals('testcontainerupdated', $containerUpdated['name']); $this->assertTrue($containerUpdated['account_grants'][0][Tinebase_Model_Grants::GRANT_ADMIN]); $deleteResult = $this->_json->deleteContainers(array($container['id'])); $this->assertEquals('success', $deleteResult['status']); }
/** * 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!'); }