Skip to content

Commit

Permalink
test: validateJson should return false when value is null
Browse files Browse the repository at this point in the history
Fails with Laravel Framework 10.38.2 in PHP < 8.3, introduced in laravel#49413
  • Loading branch information
Xint0-elab committed Dec 22, 2023
1 parent 6c53284 commit cb19e13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Exceptions\MathException;
use Illuminate\Support\Stringable;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\DatabasePresenceVerifierInterface;
Expand Down Expand Up @@ -2817,6 +2818,14 @@ public function testValidateJson()
$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => ['array']], ['foo' => 'json']);
$this->assertFalse($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => null], ['foo' => 'json']);
$this->assertFalse($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => new Stringable('[]')], ['foo' => 'json']);
$this->assertTrue($v->passes());
}

public function testValidateBoolean()
Expand Down

0 comments on commit cb19e13

Please sign in to comment.