1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-18 11:41:17 +02:00

Soften the test check for FontProcessorTest

As slightly different results can occur in different environments
with results of imageftbbox and roundings, a range is checked
instead of a fixed value.
This commit is contained in:
Oliver Vogel
2024-03-10 11:59:18 +01:00
parent ed310770a5
commit 88c24d178e

View File

@@ -63,8 +63,8 @@ final class FontProcessorTest extends BaseTestCase
$processor = new FontProcessor(); $processor = new FontProcessor();
$size = $processor->boxSize('ABC', $this->testFont()); $size = $processor->boxSize('ABC', $this->testFont());
$this->assertInstanceOf(SizeInterface::class, $size); $this->assertInstanceOf(SizeInterface::class, $size);
$this->assertEquals(74, $size->width()); $this->assertContains($size->width(), [74, 75, 76]);
$this->assertEquals(20, $size->height()); $this->assertContains($size->height(), [19, 20, 21]);
} }
public function testNativeFontSize(): void public function testNativeFontSize(): void
@@ -120,21 +120,21 @@ final class FontProcessorTest extends BaseTestCase
{ {
$processor = new FontProcessor(); $processor = new FontProcessor();
$result = $processor->typographicalSize($this->testFont()); $result = $processor->typographicalSize($this->testFont());
$this->assertEquals(45, $result); $this->assertContains($result, [44, 45]);
} }
public function testCapHeightTtf(): void public function testCapHeightTtf(): void
{ {
$processor = new FontProcessor(); $processor = new FontProcessor();
$result = $processor->capHeight($this->testFont()); $result = $processor->capHeight($this->testFont());
$this->assertEquals(45, $result); $this->assertContains($result, [44, 45]);
} }
public function testLeadingTtf(): void public function testLeadingTtf(): void
{ {
$processor = new FontProcessor(); $processor = new FontProcessor();
$result = $processor->leading($this->testFont()); $result = $processor->leading($this->testFont());
$this->assertEquals(45, $result); $this->assertContains($result, [44, 45]);
} }
private function testFont(): Font private function testFont(): Font