예제 #1
0
파일: DemoTest.php 프로젝트: qinyuguang/pbs
 public function testRest()
 {
     $data = ['result' => true];
     $result = json_encode(['errno' => 0, 'errmsg' => '', 'data' => ['result' => true]]);
     Rest::success($data);
     $this->expectOutputString($result);
 }
예제 #2
0
파일: Error.php 프로젝트: qinyuguang/pbs
 public function errorAction()
 {
     try {
         throw $this->getRequest()->getException();
     } catch (Yaf\Exception\LoadFailed $e) {
         Rest::fail(Error::getMessage(Error::NOT_FOUND), Error::NOT_FOUND);
     } catch (Doctrine\DBAL\DBALException $e) {
         Rest::fail(Error::getMessage(Error::UNAVAILABLE), Error::UNAVAILABLE);
         $logger = Logkit\Logger::ins('_dbal');
         $logger->error($e->getMessage());
     } catch (Exception $e) {
         Rest::fail($e->getMessage(), $e->getCode());
         $logger = Logkit\Logger::ins('_exception');
         $logger->error($e->getMessage());
     }
     return false;
 }