Example #1
0
 /**
  * 操作成功跳转的快捷方法
  * @access public
  * @param mixed $msg 提示信息
  * @param mixed $data 返回的数据
  * @param mixed $url 跳转的URL地址
  * @param mixed $wait 跳转等待时间
  * @return void
  */
 public function success($msg = '', $data = '', $url = '', $wait = 3)
 {
     return Response::success($msg, $data, $url, $wait);
 }
Example #2
0
 /**
  * @covers think\Response::success
  * @todo Implement testSuccess().
  */
 public function testSuccess()
 {
     // round 1
     $msg = 1001;
     $data = "data";
     $url = "www.HTTP_REFERER.com";
     if (isset($_SERVER["HTTP_REFERER"])) {
         $HTTP_REFERER = $_SERVER["HTTP_REFERER"];
     }
     $_SERVER["HTTP_REFERER"] = $url;
     Config::set('default_return_type', "json");
     $result = Response::success($msg, $data);
     $this->assertEquals($msg, $result["code"]);
     $this->assertEquals($data, $result["data"]);
     $this->assertEquals($url, $result["url"]);
     $this->assertEquals("json", Response::type());
     $this->assertEquals(3, $result["wait"]);
     // round 2
     $msg = "the msg";
     $url = "www.thinkphptestsucess.com";
     $result = Response::success($msg, $data, $url);
     $this->assertEquals($msg, $result["msg"]);
     $this->assertEquals($url, $result["url"]);
     // round 3 异常在travis-ci中未能重现
     // $this->setExpectedException('\think\Exception');
     // FIXME 静态方法mock
     // $oMockView = $this->getMockBuilder('\think\View')->setMethods(array(
     // 'fetch'
     // ))->getMock();
     // $oMockView->expects($this->any())->method('fetch')->will($this->returnValue('content'));
     // Config::set('default_return_type', "html");
     // $result = Response::success($msg, $data, $url);
     // FIXME 静态方法mock
     // $this->assertEquals('content', $result);
     if (isset($HTTP_REFERER)) {
         $_SERVER["HTTP_REFERER"] = $HTTP_REFERER;
     }
 }