From eb1ea6ea8056db0c4a2034cd69421d112bcf697d Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 17 Feb 2017 22:55:23 +0100 Subject: [PATCH] [5.4] Add test for validation of ratio with no fractional part (#17980) * Convert fixtures to PNG format * Add test for validation of ratio with no fractional part --- tests/Validation/ValidationValidatorTest.php | 18 +++++++++++++----- .../fixtures/{empty.gif => empty.png} | 0 tests/Validation/fixtures/image.gif | Bin 1097 -> 0 bytes tests/Validation/fixtures/image.png | Bin 0 -> 91 bytes tests/Validation/fixtures/image2.png | Bin 0 -> 91 bytes 5 files changed, 13 insertions(+), 5 deletions(-) rename tests/Validation/fixtures/{empty.gif => empty.png} (100%) delete mode 100644 tests/Validation/fixtures/image.gif create mode 100644 tests/Validation/fixtures/image.png create mode 100644 tests/Validation/fixtures/image2.png diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 01a954c7ab32..bab3d94b6020 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -217,8 +217,8 @@ public function testClassBasedCustomReplacers() public function testNestedAttributesAreReplacedInDimensions() { - // Knowing that demo image.gif has width = 3 and height = 2 - $uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image.gif', '', null, null, null, true); + // Knowing that demo image.png has width = 3 and height = 2 + $uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image.png', '', null, null, null, true); $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.dimensions' => ':min_width :max_height :ratio'], 'en'); @@ -1895,8 +1895,8 @@ public function testValidateImage() public function testValidateImageDimensions() { - // Knowing that demo image.gif has width = 3 and height = 2 - $uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image.gif', '', null, null, null, true); + // Knowing that demo image.png has width = 3 and height = 2 + $uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image.png', '', null, null, null, true); $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, ['x' => 'file'], ['x' => 'dimensions']); @@ -1944,8 +1944,16 @@ public function testValidateImageDimensions() $v = new Validator($trans, ['x' => $uploadedFile], ['x' => 'dimensions:ratio=1']); $this->assertTrue($v->fails()); + // Knowing that demo image2.png has width = 4 and height = 2 + $uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image2.png', '', null, null, null, true); + $trans = $this->getIlluminateArrayTranslator(); + + // Ensure validation doesn't erroneously fail when ratio has no fractional part + $v = new Validator($trans, ['x' => $uploadedFile], ['x' => 'dimensions:ratio=2/1']); + $this->assertTrue($v->passes()); + // This test fails without suppressing warnings on getimagesize() due to a read error. - $emptyUploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/empty.gif', '', null, null, null, true); + $emptyUploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/empty.png', '', null, null, null, true); $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, ['x' => $emptyUploadedFile], ['x' => 'dimensions:min_width=1']); diff --git a/tests/Validation/fixtures/empty.gif b/tests/Validation/fixtures/empty.png similarity index 100% rename from tests/Validation/fixtures/empty.gif rename to tests/Validation/fixtures/empty.png diff --git a/tests/Validation/fixtures/image.gif b/tests/Validation/fixtures/image.gif deleted file mode 100644 index db5ecb91ea7d6367bed7a68db66371a27786680e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1097 zcmZ?wbhEHbWM*JuXkcLY|NlP&1B2p!?g-xi1((E!Y#3Q(W~w5=#5%__*n4QdyVXRDM^Qc_^0uU}qXu2*iX zmtT~wZ)j<02{OaTNEfI=x41H|B(Xv_uUHvof=g;~a#3bMNoIbY0?5R~r2NtnTP2`N zAzsKWfE$}vtOxdvUUGh}ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW z)Z+ZoqU2Pda%GTJ1y;^Qsfi`|MIrh5Ij~R+$jC3rFV4s>P;d@5Q_%2DOwP;$321_K z`1)FT<`tJD<|U_ky4WfK&CtutOtCUBH!^fHay2z@G%+_cbTzXyF)(*_GO}>8Fm-b_ zHnfE4b;(aI%}vcKf$2>_=rzNs7nB%s3xGDeq!wkCrKY$Q<>xAZJ#CeV+bza8&4cPq z!R;0koO<#DphYAP1iGQ}cl7y$G1F8UO$L`{(zspFh5T`}*bc zr;i`rzkB=U^{baJoVgsyL#pFrHdENpF4Zz^r@34jvqUE zVojbN~+qz}*ri~lcuUorj^{SOCmM>enWbvYf3+B(8J7@N+nKPzO zn>uCkq=^&y`+9r2yE;4C+ge+in;IMH>uPJNt12tX%Sua%iwXi?qaq{1!$L!Xg8~Em{d|4Ay*xeK-CSLqog5wP?QCtVtt>6f%}h;lT#wKO%<)l^lKl@t}^1_KjQOFV-$0K