mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-25 17:56:18 +00:00
ec4098c8fd
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.
56 lines
1.6 KiB
PHP
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);
|
|
}
|
|
}
|