繁体   English   中英

Laravel测试

[英]Laravel testing

在我的Laravel软件包中,我正在测试api端点,但是我始终会收到404响应!

这是文件(请参阅unsuccessfulLogin方法):

https://github.com/larsjanssen6/underconstruction/blob/master/tests/Integration/UnderConstructionModeTest.php

$this->post('/under/check', ['code' => 1235]);

在我的服务提供商中:

https://github.com/larsjanssen6/underconstruction/blob/master/src/UnderConstructionServiceProvider.php

  $routeConfig = [
            'namespace'  => 'LarsJanssen\UnderConstruction\Controllers',
            'prefix'     => 'under',
            'middleware' => [
                'web',
            ],
        ];
        $this->getRouter()->group($routeConfig, function ($router) {
            $router->post('check', [
                'uses' => 'CodeController@check',
                'as'   => 'underconstruction.check',
            ]);
            $router->get('construction', [
                'uses' => 'CodeController@index',
                'as'   => 'underconstruction.index',
            ]);
            $router->get('js', [
                'uses' => 'AssetController@js',
                'as'   => 'underconstruction.js',
            ]);
        });

我注册这些路线! 在邮递员那里,它正在工作。 那为什么在我的测试中不起作用?

为什么使用$this->post() 应该是$this->get()吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM