Lumen PHPUnit测试验证

时间:2017-07-21 04:40:16

标签: php laravel laravel-5 phpunit lumen

如何在流明上进行PHPUnit表单验证? 这是因为我收到以下错误。

BadMethodCallException: Method [validateTest] does not exist.

C:\work\test\vendor\illuminate\validation\Validator.php:3360
C:\work\test\vendor\illuminate\validation\Validator.php:517
C:\work\test\vendor\illuminate\validation\Validator.php:517
C:\work\test\vendor\illuminate\validation\Validator.php:431
C:\work\test\vendor\illuminate\validation\Validator.php:456
C:\work\test\vendor\laravel\lumen-framework\src\Routing\ProvidesConvenienceMethods.php:63
C:\work\test\app\Http\Controllers\BusinessInfoController.php:30
C:\work\test\tests\app\Http\Controllers\BusinessInfoControllerTest.php:17
C:\Users\chew\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:188
C:\Users\chew\AppData\Roaming\Composer\vendor\phpunit\phpunit\src\TextUI\Command.php:118

在我的控制器上,它在此行中出错。

public function getUsers(Request $request, InfoRequest $infoRequest)
{

    $this->validate($request, $infoRequest->ruleGetInfo());
    ....
}

在InfoRequest上:

public function ruleGetInfo()
{
    return [
        'email' => 'required',
        'password' => 'required'
    ];
}

我不确定为什么要寻找validateTest方法。我甚至尝试将它添加到我的phpunit测试文件和实际的控制器文件本身(只是为了测试一下),但它仍然会出现同样的错误。

0 个答案:

没有答案