public function testCRUD() { $topic = $this->get_component_node('org.openpsa.slideshow'); midcom::get('auth')->request_sudo('org.openpsa.slideshow'); $image = new org_openpsa_slideshow_image_dba(); $image->topic = $topic->id; $stat = $image->create(); $this->assertTrue($stat); $this->register_object($image); $image->title = 'TEST'; $stat = $image->update(); $this->assertTrue($stat); $this->assertEquals('TEST', $image->title); $stat = $image->delete(); $this->assertTrue($stat); midcom::get('auth')->drop_sudo(); }
private function _process_create() { $image = new org_openpsa_slideshow_image_dba(); $image->topic = $this->_topic->id; $image->title = $_POST['title']; $image->description = $_POST['description']; $image->position = $_POST['position']; if (!$image->create()) { throw new midcom_error('Failed to create image: ' . midcom_connection::get_error_string()); } $this->_response->position = $image->position; $this->_response->guid = $image->guid; if (isset($_FILES['image'])) { $this->_upload_image($_FILES['image'], $image); } }