Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/Font3Test.php
T
Adrien Crivelli ec4098c8fd Strict mode for all tests
While we might never be able to have 100% of our code strict, we can at
the very least do it for all of our tests. This ensures that our tests
are using our API with the types as intended by the test author, and not
silently be cast to what our API requires.
2023-09-07 17:44:56 +08:00

56 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Shared;
use PhpOffice\PhpSpreadsheet\Exception as SSException;
use PhpOffice\PhpSpreadsheet\Shared\Font;
use PhpOffice\PhpSpreadsheet\Style\Font as StyleFont;
use PHPUnit\Framework\TestCase;
class Font3Test extends TestCase
{
/** @var string */
private $holdDirectory;
protected function setUp(): void
{
$this->holdDirectory = Font::getTrueTypeFontPath();
}
protected function tearDown(): void
{
Font::setTrueTypeFontPath($this->holdDirectory);
}
public function testGetTrueTypeException1(): void
{
$this->expectException(SSException::class);
$this->expectExceptionMessage('Valid directory to TrueType Font files not specified');
$font = new StyleFont();
$font->setName('unknown');
Font::getTrueTypeFontFileFromFont($font);
}
public function testGetTrueTypeException2(): void
{
Font::setTrueTypeFontPath(__DIR__);
$this->expectException(SSException::class);
$this->expectExceptionMessage('Unknown font name');
$font = new StyleFont();
$font->setName('unknown');
Font::getTrueTypeFontFileFromFont($font);
}
public function testGetTrueTypeException3(): void
{
Font::setTrueTypeFontPath(__DIR__);
$this->expectException(SSException::class);
$this->expectExceptionMessage('TrueType Font file not found');
$font = new StyleFont();
$font->setName('Calibri');
Font::getTrueTypeFontFileFromFont($font);
}
}