Skip to content

Commit

Permalink
Different Hashes for Font File (PHPOffice#3524)
Browse files Browse the repository at this point in the history
Wanting a sanity test for ExactFontTest, I used the MD5 of a known file. However, there are various versions of the file in the wild, and use of these variants cause test to be skipped. Allow known variations to satisfy MD5 check.
  • Loading branch information
oleibman authored Apr 13, 2023
1 parent 6cc2bb4 commit a77977d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/PhpSpreadsheetTests/Shared/ExactFontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class ExactFontTest extends TestCase
/** @var string */
private $incompleteMessage = '';

private const KNOWN_MD5 = [
'6a15e0a7c0367ba77a959ea27ebf11cf',
'b0e31de57cd5307954a3c54136ce68ae',
'be189a7e2711cdf2a7f6275c60cbc7e2',
];

protected function setUp(): void
{
$this->holdDirectory = Font::getTrueTypeFontPath();
Expand All @@ -57,8 +63,9 @@ protected function setUp(): void
$fontPath = $direc . $fontFile;
$this->incompleteMessage = '';
if (@is_readable($fontPath)) {
if ('6a15e0a7c0367ba77a959ea27ebf11cf' !== md5_file($fontPath)) {
$this->incompleteMessage = 'Font file MD5 hash has changed';
$hash = md5_file($fontPath);
if (!in_array($hash, self::KNOWN_MD5, true)) {
$this->incompleteMessage = "Unrecognized Font file MD5 hash $hash";
}
} else {
$this->incompleteMessage = 'Unable to locate font file';
Expand Down

0 comments on commit a77977d

Please sign in to comment.