Skip to content
Advertisement

Laravel validation testing using data provider

I have laravel rules validation and i want test it all give rules with one method and dataProvider using phpunit

For example i have rules required|string|max:255 i want test required string andmax:255` rules without writing test method separately

But i only can do it for required rules only i want test the second rules like digit_between for identity field but first_name field doesnt have digit_between but is string

  1. here my example rules code
JavaScript

2.testing code :

JavaScript

Advertisement

Answer

Each index is a one test scenario, So the first scenario is to test the required validation, the second scenario would be digits_between:1,255, We set 256 for identity_number, because you have defined a range number, and the rest as you can see.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement