Skip to content

Commit

Permalink
tests: expected .PNG changed to RAW .GD2
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 24, 2017
1 parent eed59a3 commit 2033dd4
Show file tree
Hide file tree
Showing 32 changed files with 41 additions and 20 deletions.
7 changes: 3 additions & 4 deletions tests/Utils/Image.alpha1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ $image2->place(Image::fromBlank(50, 50, Image::rgb(80, 174, 0)), 75, 25);

Assert::same($image2->toString(Image::PNG, 0), $image->toString(Image::PNG, 0));

ob_start();

$image = Image::fromBlank(200, 100, Image::rgb(255, 128, 0, 60));
$image->crop(0, 0, '60%', '60%');
$image->send(Image::PNG, 0);

Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha1.png'), ob_get_clean());
ob_start();
imagegd2($image->getImageResource());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha1.gd2'), ob_get_clean());
22 changes: 15 additions & 7 deletions tests/Utils/Image.alpha2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,44 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 100);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 99);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 50);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 1);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 0);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 100);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.gd2'), toGd2($image));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 50);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.gd2'), toGd2($image));
12 changes: 10 additions & 2 deletions tests/Utils/Image.drawing.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


$size = 300;
$image = Image::fromBlank($size, $size);

Expand All @@ -28,11 +36,11 @@ $image->filledEllipse(187, 125, $radius, $radius, Image::rgb(0, 0, 255, 75));

$image->copyResampled($image, 200, 200, 0, 0, 80, 80, $size, $size);

Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.1.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.1.gd2'), toGd2($image));


// palette-based image
$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');
$image->filledEllipse(100, 50, 50, 50, Image::rgb(255, 255, 0, 75));
$image->filledEllipse(100, 150, 50, 50, Image::rgb(255, 255, 0, 75));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.gd2'), toGd2($image));
6 changes: 2 additions & 4 deletions tests/Utils/Image.place.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ $image = Image::fromBlank(100, 100, Image::rgb(0, 0, 0));
$image->place($rectangle, '37.5%', '50%');

ob_start();

$image->send(Image::PNG, 0);

Assert::same(file_get_contents(__DIR__ . '/expected/Image.place.png'), ob_get_clean());
imagegd2($image->getImageResource());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.place.gd2'), ob_get_clean());
14 changes: 11 additions & 3 deletions tests/Utils/Image.resize.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ require __DIR__ . '/../bootstrap.php';
$main = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


test(function () use ($main) { // cropping...
$image = clone $main;
Assert::same(176, $image->width);
Expand Down Expand Up @@ -135,19 +143,19 @@ test(function () use ($main) { // rotate
test(function () use ($main) { // alpha resize
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->resize(20, 20);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.gd2'), toGd2($image));
});


test(function () use ($main) { // alpha flip
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->resize(-10, -10);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.gd2'), toGd2($image));
});


test(function () use ($main) { // palette alpha resize
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif');
$image->resize(20, 20);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.png'), $image->toString(Image::PNG, 0));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.gd2'), toGd2($image));
});
Binary file added tests/Utils/expected/Image.alpha.flip1.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha.flip1.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha.resize1.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha.resize1.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha.resize2.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha.resize2.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha1.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha1.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.0.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.0.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.1.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.1.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.100.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.100.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.100b.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.100b.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.50.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.50.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.50b.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.50b.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.99.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha2.99.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.drawing.1.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.drawing.1.png
Binary file not shown.
Binary file added tests/Utils/expected/Image.drawing.2.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.drawing.2.png
Binary file not shown.
Binary file not shown.

0 comments on commit 2033dd4

Please sign in to comment.