-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor RemoveAnimationModifier::class, Add tests
- Loading branch information
1 parent
ca067a8
commit 5a1b6f5
Showing
4 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Tests\Unit\Modifiers; | ||
|
||
use Generator; | ||
use Intervention\Image\Interfaces\ImageInterface; | ||
use Intervention\Image\Modifiers\RemoveAnimationModifier; | ||
use Intervention\Image\Tests\BaseTestCase; | ||
use Mockery; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
|
||
#[CoversClass(RemoveAnimationModifier::class)] | ||
final class RemoveAnimationModifierTest extends BaseTestCase | ||
{ | ||
#[DataProvider('normalizePositionProvider')] | ||
public function testNormalizePosition(int|string $position, int $frames, int $normalized): void | ||
{ | ||
$modifier = new class ($position) extends RemoveAnimationModifier | ||
{ | ||
public function testResult(int $frames): int | ||
{ | ||
$image = Mockery::mock(ImageInterface::class)->makePartial(); | ||
$image->shouldReceive('count')->andReturn($frames); | ||
|
||
return $this->normalizePosition($image); | ||
} | ||
}; | ||
|
||
$this->assertEquals($normalized, $modifier->testResult($frames)); | ||
} | ||
|
||
public static function normalizePositionProvider(): Generator | ||
{ | ||
yield [0, 100, 0]; | ||
yield [10, 100, 10]; | ||
yield ['10', 100, 10]; | ||
yield ['0%', 100, 0]; | ||
yield ['50%', 100, 50]; | ||
yield ['100%', 100, 99]; | ||
} | ||
} |