|
5 | 5 | use Illuminate\Filesystem\Filesystem; |
6 | 6 | use Illuminate\Support\Facades\Config; |
7 | 7 | use function Pest\Laravel\artisan; |
8 | | -use function PHPUnit\Framework\assertStringEqualsFile; |
| 8 | +use function PHPUnit\Framework\assertEquals; |
9 | 9 |
|
10 | 10 | test('Check valid creating Laravel Validation Rules in Request with application/json content type', function () { |
11 | 11 | /** @var TestCase $this */ |
|
37 | 37 | $validationsEnd = strpos($request, '];', $validationsStart) + 2; |
38 | 38 | $validations = substr($request, $validationsStart, $validationsEnd - $validationsStart); |
39 | 39 |
|
40 | | - assertStringEqualsFile(__DIR__ . '/expects/LaravelValidationsApplicationJsonRequest.php', $validations); |
| 40 | + // For test on Windows replace \r\n to \n |
| 41 | + $actual = str_replace("\r\n", "\n", $validations); |
| 42 | + $expect = str_replace("\r\n", |
| 43 | + "\n", |
| 44 | + file_get_contents(__DIR__ . '/expects/LaravelValidationsApplicationJsonRequest.php') |
| 45 | + ); |
| 46 | + |
| 47 | + assertEquals($expect, $actual, $validations); |
41 | 48 | }); |
42 | 49 |
|
43 | 50 | test('Check valid creating Laravel Validation Rules in Request with multipart/form-data content type', function () { |
|
70 | 77 | $validationsEnd = strpos($request, '];', $validationsStart) + 2; |
71 | 78 | $validations = substr($request, $validationsStart, $validationsEnd - $validationsStart); |
72 | 79 |
|
73 | | - assertStringEqualsFile(__DIR__ . '/expects/LaravelValidationsMultipartFormDataRequest.php', $validations); |
| 80 | + // For test on Windows replace \r\n to \n |
| 81 | + $actual = str_replace("\r\n", "\n", $validations); |
| 82 | + $expect = str_replace("\r\n", |
| 83 | + "\n", |
| 84 | + file_get_contents(__DIR__ . '/expects/LaravelValidationsMultipartFormDataRequest.php') |
| 85 | + ); |
| 86 | + |
| 87 | + assertEquals($expect, $actual, $validations); |
74 | 88 | }); |
75 | 89 |
|
76 | 90 | test('Check valid creating Laravel Validation Rules in Request with non available content type', function () { |
|
102 | 116 | $validationsStart = strpos($request, "public function rules(): array") + 37; |
103 | 117 | $validationsEnd = strpos($request, '];', $validationsStart) + 2; |
104 | 118 | $validations = substr($request, $validationsStart, $validationsEnd - $validationsStart); |
| 119 | + |
105 | 120 | // For test on Windows replace \r\n to \n |
106 | | - $validations = str_replace("\r\n", "\n", $validations); |
| 121 | + $actual = str_replace("\r\n", "\n", $validations); |
| 122 | + $expect = str_replace("\r\n", |
| 123 | + "\n", |
| 124 | + file_get_contents(__DIR__ . '/expects/LaravelValidationsNonAvailableContentTypeRequest.php') |
| 125 | + ); |
107 | 126 |
|
108 | | - assertStringEqualsFile(__DIR__ . '/expects/LaravelValidationsNonAvailableContentTypeRequest.php', $validations); |
| 127 | + assertEquals($expect, $actual, $validations); |
109 | 128 | }); |
0 commit comments