diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 8da894b85620..9df10d9431b8 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1347,7 +1347,7 @@ public function validateHexColor($attribute, $value) */ public function validateImage($attribute, $value) { - return $this->validateMimes($attribute, $value, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']); + return $this->validateMimes($attribute, $value, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'avif']); } /** diff --git a/tests/Validation/ValidationFileRuleTest.php b/tests/Validation/ValidationFileRuleTest.php index 1705a3ef198b..ce8dbd8cc7e4 100644 --- a/tests/Validation/ValidationFileRuleTest.php +++ b/tests/Validation/ValidationFileRuleTest.php @@ -192,6 +192,12 @@ public function testImage() File::image(), UploadedFile::fake()->image('foo.png'), ); + + $this->passes( + File::image(), + UploadedFile::fake()->image('foo.avif'), + ['validation.image'] + ); } public function testSize() diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index a1c49716febf..2dc646ad8950 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -4846,12 +4846,6 @@ public function testValidateImage() $v = new Validator($trans, ['x' => $file2], ['x' => 'image']); $this->assertTrue($v->passes()); - $file2 = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); - $file2->expects($this->any())->method('guessExtension')->willReturn('jpg'); - $file2->expects($this->any())->method('getClientOriginalExtension')->willReturn('jpg'); - $v = new Validator($trans, ['x' => $file2], ['x' => 'image']); - $this->assertTrue($v->passes()); - $file3 = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); $file3->expects($this->any())->method('guessExtension')->willReturn('gif'); $file3->expects($this->any())->method('getClientOriginalExtension')->willReturn('gif'); @@ -4883,10 +4877,9 @@ public function testValidateImage() $v = new Validator($trans, ['x' => $file7], ['x' => 'Image']); $this->assertTrue($v->passes()); - $file2 = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); - $file2->expects($this->any())->method('guessExtension')->willReturn('jpg'); - $file2->expects($this->any())->method('getClientOriginalExtension')->willReturn('jpg'); - $v = new Validator($trans, ['x' => $file2], ['x' => 'Image']); + $file8 = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); + $file8->expects($this->any())->method('guessExtension')->willReturn('avif'); + $file8->expects($this->any())->method('getClientOriginalExtension')->willReturn('avif'); $v = new Validator($trans, ['x' => $file8], ['x' => 'Image']); $this->assertTrue($v->passes()); }