public function testRemove() { $t = new Task($this->registry); $p = new Project($this->registry); $c = new Category($this->registry); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1))); $this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1))); $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2))); $task = $t->getById(1); $this->assertTrue(is_array($task)); $this->assertEquals(2, $task['category_id']); $this->assertTrue($c->remove(1)); $this->assertTrue($c->remove(2)); // Make sure tasks assigned with that category are reseted $task = $t->getById(1); $this->assertTrue(is_array($task)); $this->assertEquals(0, $task['category_id']); }
list($valid, ) = $category->validateCreation($values); return $valid && $category->create($values); }); $server->register('getCategory', function ($category_id) use($category) { return $category->getById($category_id); }); $server->register('getAllCategories', function ($project_id) use($category) { return $category->getAll($project_id); }); $server->register('updateCategory', function ($id, $name) use($category) { $values = array('id' => $id, 'name' => $name); list($valid, ) = $category->validateModification($values); return $valid && $category->update($values); }); $server->register('removeCategory', function ($category_id) use($category) { return $category->remove($category_id); }); /** * Comments procedures */ $server->register('createComment', function (array $values) use($comment) { list($valid, ) = $comment->validateCreation($values); return $valid && $comment->create($values); }); $server->register('getComment', function ($comment_id) use($comment) { return $comment->getById($comment_id); }); $server->register('getAllComments', function ($task_id) use($comment) { return $comment->getAll($task_id); }); $server->register('updateComment', function ($values) use($comment) {