X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraints%2FImageValidatorTest.php;fp=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraints%2FImageValidatorTest.php;h=93b1d05bab7b2d623c78213866dcdc56f5a8ba84;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=4605a06577a8a6aa154a6a2865a6c41cafc94f25;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php b/vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php index 4605a0657..93b1d05ba 100644 --- a/vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php +++ b/vendor/symfony/validator/Tests/Constraints/ImageValidatorTest.php @@ -13,12 +13,12 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\ImageValidator; -use Symfony\Component\Validator\Validation; +use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; /** * @requires extension fileinfo */ -class ImageValidatorTest extends AbstractConstraintValidatorTest +class ImageValidatorTest extends ConstraintValidatorTestCase { protected $context; @@ -32,11 +32,7 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest protected $imageLandscape; protected $imagePortrait; protected $image4By3; - - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } + protected $imageCorrupted; protected function createValidator() { @@ -51,6 +47,7 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest $this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif'; $this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif'; $this->image4By3 = __DIR__.'/Fixtures/test_4by3.gif'; + $this->imageCorrupted = __DIR__.'/Fixtures/test_corrupted.gif'; } public function testNullIsValid() @@ -329,4 +326,26 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest ->setCode(Image::PORTRAIT_NOT_ALLOWED_ERROR) ->assertRaised(); } + + public function testCorrupted() + { + if (!function_exists('imagecreatefromstring')) { + $this->markTestSkipped('This test require GD extension'); + } + + $constraint = new Image(array( + 'detectCorrupted' => true, + 'corruptedMessage' => 'myMessage', + )); + + $this->validator->validate($this->image, $constraint); + + $this->assertNoViolation(); + + $this->validator->validate($this->imageCorrupted, $constraint); + + $this->buildViolation('myMessage') + ->setCode(Image::CORRUPTED_IMAGE_ERROR) + ->assertRaised(); + } }