public function test_delete() { $as = XAppSession::begin(); $name = "testname_delete"; $authorService = new AuthorService(); $author = $authorService->add($name); $as->commit(); $this->logger->info("Author status before: " . $author->getStatus()); $this->assertTrue(!is_null($author) && $author->getStatus() == Constants::USING); $author = $authorService->delete($author->id()); $as->commit(); $this->logger->info("Author status after: " . $author->getStatus()); $this->assertTrue(!is_null($author) && $author->getStatus() == Constants::DELETED); Dwriter::ins()->del_Author_by_id($author->id()); $as->commit(); $as = null; }
public function _run($request, $xcontext) { $name = Utils::testInput($request->name); $this->logger->info("Input name: {$name}"); if (empty($name)) { $this->logger->error("Input name is empty!"); throw new Exception("need name!"); } $authorService = new AuthorService(); $author = $authorService->add($name); $this->logger->info("Create an author named {$name}"); if (!$author || $author->id() <= 0) { $this->logger->error("failed in adding author!"); throw new Exception("failed in adding author!"); } return XNext::action("listauthor"); }