Exemplo n.º 1
0
 public function test_update()
 {
     $as = XAppSession::begin();
     $name = "testname_before";
     $authorService = new AuthorService();
     $author = $authorService->add($name);
     $as->commit();
     $this->logger->info("Author name before: " . $author->getName());
     $this->assertTrue(!is_null($author) && strcmp($author->getName(), $name) == 0);
     $name = "testname_after";
     $author = $authorService->update($author->id(), $name);
     $as->commit();
     $this->logger->info("Author name after: " . $author->getName());
     $this->assertTrue(!is_null($author) && strcmp($author->getName(), $name) == 0);
     Dwriter::ins()->del_Author_by_id($author->id());
     $as->commit();
     $as = null;
 }
Exemplo n.º 2
0
 public function _run($request, $xcontext)
 {
     $id = intval(Utils::testInput($request->id));
     $name = Utils::testInput($request->name);
     $this->logger->info("Input id: {$id}, name: {$name}");
     if (empty($id) || empty($name)) {
         $this->logger->error("Input id or name is empty!");
         throw new Exception("Input id or name is empty!");
     }
     $authorService = new AuthorService();
     $author = $authorService->update($id, $name);
     $this->logger->info("Update an author whose id is {$id} and named {$name}");
     if (!$author || $author->id() <= 0) {
         $this->logger->error("failed in updating author!");
         throw new Exception("failed in updating author!");
     }
     return XNext::action("listauthor");
 }