Skip to content

Commit 802cb65

Browse files
committed
Add tests for References::rotation
1 parent 614ec3b commit 802cb65

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Tests/References/RotationTest.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 RotationTest extends TestCase
20+
{
21+
/**
22+
* @dataProvider provideValidRotationValues
23+
*/
24+
public function testValidRotation(string $value)
25+
{
26+
static::assertSame(\trim($value), (new References())->rotation($value));
27+
}
28+
29+
public function provideValidRotationValues(): \Generator
30+
{
31+
yield ['1'];
32+
yield ['-1'];
33+
yield [' 360'];
34+
yield ['-360 '];
35+
yield ['1>'];
36+
yield ['-1>'];
37+
yield ['360.5>'];
38+
yield ['-360.5>'];
39+
yield ['1<'];
40+
yield ['-1<'];
41+
yield [' 360<'];
42+
yield ['-360< '];
43+
}
44+
/**
45+
* @dataProvider provideInvalidRotationValues
46+
*/
47+
public function testInvalidRotation(string $value)
48+
{
49+
$this->expectException(\InvalidArgumentException::class);
50+
$this->expectExceptionMessage(\sprintf('The specified rotate parameter (%s) is invalid.'."\n".'Please refer to ImageMagick command line documentation about the "-rotate" option:'."\n%s", \trim($value), 'http://www.imagemagick.org/script/command-line-options.php#rotate'));
51+
52+
static::assertSame($value, (new References())->rotation($value));
53+
}
54+
55+
public function provideInvalidRotationValues(): \Generator
56+
{
57+
yield ['a'];
58+
yield ['-1a'];
59+
yield [' abc '];
60+
yield ['0,5'];
61+
yield [''];
62+
}
63+
}

0 commit comments

Comments
 (0)