0

How to PHPUnit form validation on lumen? This is because I am receiving the following error.

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

On my controller, it error out on this line.

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

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

While on the InfoRequest:

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

I'm not sure why is it looking for a validateTest method. I even tried adding it on my phpunit test file and the actual controller file itself (just to test things out) but it still gives the same error.

5
  • Extra comma remove Use this public function getUsers(Request $request, InfoRequest $infoRequest){ instead of public function getUsers(Request $request, InfoRequest, $infoRequest) {
    – RJParikh
    Jul 21, 2017 at 4:46
  • Removed extra comma. Though it has nothing to do with the error stated. It is just a typo on my end typing it down here.
    – basagabi
    Jul 21, 2017 at 4:49
  • which version of lumen are you using?
    – ayip
    Jul 22, 2017 at 20:47
  • I am using Lumen 5.3.3
    – basagabi
    Jul 23, 2017 at 23:24
  • add your test file Jul 26, 2017 at 6:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.