Laravel5.1 写测试用例时如何获取跳转后的正文内容

$content=$this->get('/guest/register?game=1',['pos'=>0])->followRedirects()->seeJson([
            'status'=>'success'
            ])->response->getContent();
$rs=json_decode($content,true);

此时content内容为空,但是会在console中打印出跳转后的json输出。

样例输出:

PHPUnit 4.8.16 by Sebastian Bergmann and contributors.

F{"status":"success","uid":"318480477","username":"dmzw-318480477","usertoken":"xmTSTGlSKFJpYFqpNG58EvlTDa6VdZaT"}

Time: 927 ms, Memory: 18.75Mb

There was 1 failure:

1) GuestTest::testGuestregister
Invalid JSON was returned from the route. Perhaps an exception was thrown?

/var/www/laravel/mapi_2144_cn/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:248
/var/www/laravel/mapi_2144_cn/vendor/laravel/framework/src/Illuminate/Foundation/Testing/CrawlerTrait.php:220
/var/www/laravel/mapi_2144_cn/tests/GuestTest.php:15

FAILURES!
Tests: 1, Assertions: 4, Failures: 1.
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 1

可以直接用 $this->fail("11111111111111") 输出内容

7年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!