Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit dfe26e0

Browse files
author
Andrey Helldar
authored
Merge pull request #69 from TheDragonCode/9.x
Fixed tests for Laravel 7
2 parents d200090 + a6f357f commit dfe26e0

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"symfony/http-foundation": "^4.0 || ^5.0 || ^6.0"
3333
},
3434
"require-dev": {
35+
"dragon-code/laravel-support": "^3.3",
3536
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0"
3637
},
3738
"conflict": {

tests/Fixtures/Concerns/Validationable.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace Tests\Fixtures\Concerns;
1919

20+
use DragonCode\LaravelSupport\Facades\AppVersion;
2021
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
2122
use Illuminate\Support\Facades\Validator;
2223
use Illuminate\Validation\ValidationException;
@@ -70,4 +71,9 @@ protected function validateException(array $data)
7071
? new ValidationException($validator)
7172
: $validator->validated();
7273
}
74+
75+
protected function validationUrlMessage(): array
76+
{
77+
return AppVersion::is7x() ? ['The baz format is invalid.'] : ['The baz must be a valid URL.'];
78+
}
7379
}

tests/Laravel/Parsers/Validation/NoWithDataTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ public function testStructure()
5757
$this->validationResponse([])->getJson()
5858
);
5959

60-
$this->assertSame(
61-
[
62-
'error' => [
63-
'type' => 'ValidationException',
64-
'data' => [
65-
'foo' => ['The foo field is required.'],
66-
'baz' => ['The baz must be a valid URL.'],
67-
],
60+
$this->assertSame([
61+
'error' => [
62+
'type' => 'ValidationException',
63+
'data' => [
64+
'foo' => ['The foo field is required.'],
65+
'baz' => $this->validationUrlMessage(),
6866
],
6967
],
68+
],
7069
$this->validationResponse(['baz' => 0])->getJson()
7170
);
7271

@@ -77,7 +76,7 @@ public function testStructure()
7776
'data' => [
7877
'foo' => ['The foo field is required.'],
7978
'bar' => ['The bar must be an integer.'],
80-
'baz' => ['The baz must be a valid URL.'],
79+
'baz' => $this->validationUrlMessage(),
8180
],
8281
],
8382
],

tests/Laravel/Parsers/Validation/NoWithNoDataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testStructure()
6565
'type' => 'ValidationException',
6666
'data' => [
6767
'foo' => ['The foo field is required.'],
68-
'baz' => ['The baz must be a valid URL.'],
68+
'baz' => $this->validationUrlMessage(),
6969
],
7070
],
7171
],
@@ -79,7 +79,7 @@ public function testStructure()
7979
'data' => [
8080
'foo' => ['The foo field is required.'],
8181
'bar' => ['The bar must be an integer.'],
82-
'baz' => ['The baz must be a valid URL.'],
82+
'baz' => $this->validationUrlMessage(),
8383
],
8484
],
8585
],

tests/Laravel/Parsers/Validation/WithDataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testStructure()
6262
'type' => 'ValidationException',
6363
'data' => [
6464
'foo' => ['The foo field is required.'],
65-
'baz' => ['The baz must be a valid URL.'],
65+
'baz' => $this->validationUrlMessage(),
6666
],
6767
],
6868
],
@@ -76,7 +76,7 @@ public function testStructure()
7676
'data' => [
7777
'foo' => ['The foo field is required.'],
7878
'bar' => ['The bar must be an integer.'],
79-
'baz' => ['The baz must be a valid URL.'],
79+
'baz' => $this->validationUrlMessage(),
8080
],
8181
],
8282
],

tests/Laravel/Parsers/Validation/WithNoDataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testStructure()
6464
'type' => 'ValidationException',
6565
'data' => [
6666
'foo' => ['The foo field is required.'],
67-
'baz' => ['The baz must be a valid URL.'],
67+
'baz' => $this->validationUrlMessage(),
6868
],
6969
],
7070
],
@@ -78,7 +78,7 @@ public function testStructure()
7878
'data' => [
7979
'foo' => ['The foo field is required.'],
8080
'bar' => ['The bar must be an integer.'],
81-
'baz' => ['The baz must be a valid URL.'],
81+
'baz' => $this->validationUrlMessage(),
8282
],
8383
],
8484
],

0 commit comments

Comments
 (0)