From 0ecc2589023f8d0b51353c2cdd04f683342e1a61 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sun, 28 Jul 2019 00:55:18 -0400 Subject: [PATCH] Add WEBP to image validation rule --- src/Illuminate/Validation/Concerns/ValidatesAttributes.php | 2 +- tests/Validation/ValidationValidatorTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index f751ea9e394d..4638ee08bd80 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -988,7 +988,7 @@ public function validateLte($attribute, $value, $parameters) */ public function validateImage($attribute, $value) { - return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg']); + return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']); } /** diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 1d21dadedcc7..8b8f04a24cd0 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -2436,6 +2436,12 @@ public function testValidateImage() $file6->expects($this->any())->method('getClientOriginalExtension')->will($this->returnValue('svg')); $v = new Validator($trans, ['x' => $file6], ['x' => 'Image']); $this->assertTrue($v->passes()); + + $file7 = $this->getMockBuilder(UploadedFile::class)->setMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); + $file7->expects($this->any())->method('guessExtension')->will($this->returnValue('webp')); + $file7->expects($this->any())->method('getClientOriginalExtension')->will($this->returnValue('webp')); + $v = new Validator($trans, ['x' => $file7], ['x' => 'Image']); + $this->assertTrue($v->passes()); } public function testValidateImageDoesNotAllowPhpExtensionsOnImageMime()