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

Fixed tests for Laravel 7 #69

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"symfony/http-foundation": "^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
"dragon-code/laravel-support": "^3.3",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"conflict": {
Expand Down
6 changes: 6 additions & 0 deletions tests/Fixtures/Concerns/Validationable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace Tests\Fixtures\Concerns;

use DragonCode\LaravelSupport\Facades\AppVersion;
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -70,4 +71,9 @@ protected function validateException(array $data)
? new ValidationException($validator)
: $validator->validated();
}

protected function validationUrlMessage(): array
{
return AppVersion::is7x() ? ['The baz format is invalid.'] : ['The baz must be a valid URL.'];
}
}
17 changes: 8 additions & 9 deletions tests/Laravel/Parsers/Validation/NoWithDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ public function testStructure()
$this->validationResponse([])->getJson()
);

$this->assertSame(
[
'error' => [
'type' => 'ValidationException',
'data' => [
'foo' => ['The foo field is required.'],
'baz' => ['The baz must be a valid URL.'],
],
$this->assertSame([
'error' => [
'type' => 'ValidationException',
'data' => [
'foo' => ['The foo field is required.'],
'baz' => $this->validationUrlMessage(),
],
],
],
$this->validationResponse(['baz' => 0])->getJson()
);

Expand All @@ -77,7 +76,7 @@ public function testStructure()
'data' => [
'foo' => ['The foo field is required.'],
'bar' => ['The bar must be an integer.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Laravel/Parsers/Validation/NoWithNoDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testStructure()
'type' => 'ValidationException',
'data' => [
'foo' => ['The foo field is required.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand All @@ -79,7 +79,7 @@ public function testStructure()
'data' => [
'foo' => ['The foo field is required.'],
'bar' => ['The bar must be an integer.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Laravel/Parsers/Validation/WithDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testStructure()
'type' => 'ValidationException',
'data' => [
'foo' => ['The foo field is required.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand All @@ -76,7 +76,7 @@ public function testStructure()
'data' => [
'foo' => ['The foo field is required.'],
'bar' => ['The bar must be an integer.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Laravel/Parsers/Validation/WithNoDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testStructure()
'type' => 'ValidationException',
'data' => [
'foo' => ['The foo field is required.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand All @@ -78,7 +78,7 @@ public function testStructure()
'data' => [
'foo' => ['The foo field is required.'],
'bar' => ['The bar must be an integer.'],
'baz' => ['The baz must be a valid URL.'],
'baz' => $this->validationUrlMessage(),
],
],
],
Expand Down