Skip to content

Commit a3e8312

Browse files
committed
Speed up samples tests by not comparing individual pixels but image content directly
1 parent 75b7951 commit a3e8312

1 file changed

Lines changed: 5 additions & 29 deletions

File tree

tests/Samples/SamplesTest.php

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,10 @@ private static function assertImage(string $expectedImagePath, string $actualIma
5757
throw new RuntimeException(sprintf('Unable to load expected image "%s"', $expectedImagePath));
5858
}
5959

60-
if (str_ends_with($expectedImagePath, '.tiff')) { // gd doesn't have support for tiff so we have to compare the raw content
61-
static::assertSame(
62-
$expectedImageContent,
63-
$actualImageContent,
64-
$imageName,
65-
);
66-
67-
return;
68-
}
69-
70-
if (($expectedImage = imagecreatefromstring($expectedImageContent)) === false) {
71-
throw new RuntimeException(sprintf('Unable to load expected image "%s"', $imageName));
72-
}
73-
74-
if (($actualImage = imagecreatefromstring($actualImageContent)) === false) {
75-
throw new RuntimeException(sprintf('Unable to load actual image "%s"', $imageName));
76-
}
77-
78-
static::assertSame(imagesx($expectedImage), imagesx($actualImage), $imageName);
79-
static::assertSame(imagesy($expectedImage), imagesy($actualImage), $imageName);
80-
for ($x = 0; $x < imagesx($expectedImage); $x++) {
81-
for ($y = 0; $y < imagesy($expectedImage); $y++) {
82-
static::assertSame(
83-
imagecolorat($expectedImage, $x, $y),
84-
imagecolorat($actualImage, $x, $y),
85-
$imageName,
86-
);
87-
}
88-
}
60+
static::assertSame(
61+
$expectedImageContent,
62+
$actualImageContent,
63+
$imageName,
64+
);
8965
}
9066
}

0 commit comments

Comments
 (0)