|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the OrbitaleImageMagickPHP package. |
| 7 | + * |
| 8 | + * (c) Alexandre Rock Ancelet <alex@orbitale.io> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Orbitale\Component\ImageMagick\Tests\References; |
| 15 | + |
| 16 | +use Orbitale\Component\ImageMagick\References; |
| 17 | +use PHPUnit\Framework\TestCase; |
| 18 | + |
| 19 | +class BlurTest extends TestCase |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @dataProvider provideInvalidOptions |
| 23 | + */ |
| 24 | + public function testInvalidBlurOptions($invalidOption): void |
| 25 | + { |
| 26 | + $this->expectException(\InvalidArgumentException::class); |
| 27 | + $this->expectExceptionMessage('Gaussian blur must respect formats "{radius}" or "{radius}x{sigma}".'."\n" |
| 28 | + .'Please refer to ImageMagick command line documentation about the "-gaussian-blur" and "-blur" options:'."\n" |
| 29 | + .'http://www.imagemagick.org/script/command-line-options.php#blur'."\n" |
| 30 | + .'http://www.imagemagick.org/script/command-line-options.php#gaussian-blur'); |
| 31 | + $this->getReferences()->blur($invalidOption); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @dataProvider provideValidOptions |
| 36 | + */ |
| 37 | + public function testValidBlurOptions($validOption, $expectedReturn): void |
| 38 | + { |
| 39 | + static::assertSame($expectedReturn, $this->getReferences()->blur($validOption)); |
| 40 | + } |
| 41 | + |
| 42 | + public function getReferences(): References |
| 43 | + { |
| 44 | + return new References(); |
| 45 | + } |
| 46 | + |
| 47 | + public function provideInvalidOptions(): \Generator |
| 48 | + { |
| 49 | + yield ['invalid']; |
| 50 | + yield ['axb']; |
| 51 | + yield [' a x b']; |
| 52 | + yield ['1x2x3']; |
| 53 | + yield ['1 x2']; |
| 54 | + yield ['1x 2']; |
| 55 | + } |
| 56 | + |
| 57 | + public function provideValidOptions(): \Generator |
| 58 | + { |
| 59 | + yield [1, '1']; |
| 60 | + yield [-1, '-1']; |
| 61 | + yield ['1', '1']; |
| 62 | + yield ['-1', '-1']; |
| 63 | + yield ['1x2', '1x2']; |
| 64 | + yield [' 1x2 ', '1x2']; |
| 65 | + } |
| 66 | +} |
0 commit comments