Larave 单元测试,Call 方法传递的参数,Request 无法接收

<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class TestUser extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testStoreUser()
    {
        $response = $this->call('POST','/api/users',[
            'name'=>str_random(10),
            'true_name'=>str_random(5),
            'email'=>str_random('10').'@gmail.com',
            'department_id'=>0,
            'password'=>123456,
            'address'=>'',
            'phone'=>'0551-8959125',
            'mobile_phone'=>'13214789512',
            'usb_key'=>'',
        ]);
        $this->assertEquals(200,$response->getStatusCode());

        //$this->assertTrue(true);
    }
}

class UserController {
        public function store(Request $request)
        {
                //.....
                return $request->input('name')
        }
}

返回的却是如下图:
file
真是奇怪,不知道是什么原因?有遇到过的朋友吗?
PS:打印出来的log,获取的$request->all()也是空。

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 3

@lx1036 感觉你的回答,use Illum.....肯定写了,我用的是api,在api.php里面定义的resource路由,找不到原因,好奇怪,也用了json同样的都是提交不了参数

7年前 评论

@lx1036 感谢,打错了!

7年前 评论

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