-
-
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.
Merge pull request #1361 from Intervention/hotfix/cover-modifier-size
Fix bug in cover modifiers
- Loading branch information
Showing
10 changed files
with
98 additions
and
3 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
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Tests\Unit\Drivers\Gd\Modifiers; | ||
|
||
use Intervention\Image\Drivers\Gd\Modifiers\CoverDownModifier; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\RequiresPhpExtension; | ||
use Intervention\Image\Tests\GdTestCase; | ||
|
||
#[RequiresPhpExtension('gd')] | ||
#[CoversClass(\Intervention\Image\Modifiers\CoverModifier::class)] | ||
#[CoversClass(\Intervention\Image\Drivers\Gd\Modifiers\CoverModifier::class)] | ||
final class CoverDownModifierTest extends GdTestCase | ||
{ | ||
public function testModify(): void | ||
{ | ||
$image = $this->readTestImage('blocks.png'); | ||
$this->assertEquals(640, $image->width()); | ||
$this->assertEquals(480, $image->height()); | ||
$image->modify(new CoverDownModifier(100, 100, 'center')); | ||
$this->assertEquals(100, $image->width()); | ||
$this->assertEquals(100, $image->height()); | ||
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90)); | ||
$this->assertColor(0, 255, 0, 255, $image->pickColor(65, 70)); | ||
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52)); | ||
$this->assertTransparency($image->pickColor(90, 30)); | ||
} | ||
|
||
public function testModifyOddSize(): void | ||
{ | ||
$image = $this->createTestImage(375, 250); | ||
$image->modify(new CoverDownModifier(240, 90, 'center')); | ||
$this->assertEquals(240, $image->width()); | ||
$this->assertEquals(90, $image->height()); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
tests/Unit/Drivers/Imagick/Modifiers/CoverDownModifierTest.php
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\RequiresPhpExtension; | ||
use Intervention\Image\Modifiers\CoverDownModifier; | ||
use Intervention\Image\Tests\ImagickTestCase; | ||
|
||
#[RequiresPhpExtension('imagick')] | ||
#[CoversClass(\Intervention\Image\Modifiers\CoverModifier::class)] | ||
#[CoversClass(\Intervention\Image\Drivers\Imagick\Modifiers\CoverModifier::class)] | ||
final class CoverDownModifierTest extends ImagickTestCase | ||
{ | ||
public function testModify(): void | ||
{ | ||
$image = $this->readTestImage('blocks.png'); | ||
$this->assertEquals(640, $image->width()); | ||
$this->assertEquals(480, $image->height()); | ||
$image->modify(new CoverDownModifier(100, 100, 'center')); | ||
$this->assertEquals(100, $image->width()); | ||
$this->assertEquals(100, $image->height()); | ||
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90)); | ||
$this->assertColor(0, 255, 0, 255, $image->pickColor(65, 70)); | ||
$this->assertColor(0, 0, 255, 255, $image->pickColor(70, 52)); | ||
$this->assertTransparency($image->pickColor(90, 30)); | ||
} | ||
|
||
public function testModifyOddSize(): void | ||
{ | ||
$image = $this->createTestImage(375, 250); | ||
$image->modify(new CoverDownModifier(240, 90, 'center')); | ||
$this->assertEquals(240, $image->width()); | ||
$this->assertEquals(90, $image->height()); | ||
} | ||
} |
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