PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/FontTest.php

87 lines
2.2 KiB
PHP
Raw Permalink Normal View History

<?php
namespace PhpOffice\PhpSpreadsheetTests\Shared;
use PhpOffice\PhpSpreadsheet\Shared\Font;
use PHPUnit\Framework\TestCase;
class FontTest extends TestCase
{
2020-05-18 04:49:57 +00:00
public function testGetAutoSizeMethod(): void
2015-05-17 13:00:02 +00:00
{
$expectedResult = Font::AUTOSIZE_METHOD_APPROX;
$result = Font::getAutoSizeMethod();
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2020-05-18 04:49:57 +00:00
public function testSetAutoSizeMethod(): void
2015-05-17 13:00:02 +00:00
{
$autosizeMethodValues = [
Font::AUTOSIZE_METHOD_EXACT,
Font::AUTOSIZE_METHOD_APPROX,
];
2015-05-17 13:00:02 +00:00
foreach ($autosizeMethodValues as $autosizeMethodValue) {
$result = Font::setAutoSizeMethod($autosizeMethodValue);
self::assertTrue($result);
2015-05-17 13:00:02 +00:00
}
}
2020-05-18 04:49:57 +00:00
public function testSetAutoSizeMethodWithInvalidValue(): void
2015-05-17 13:00:02 +00:00
{
$unsupportedAutosizeMethod = 'guess';
$result = Font::setAutoSizeMethod($unsupportedAutosizeMethod);
self::assertFalse($result);
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerFontSizeToPixels
*
* @param mixed $expectedResult
*/
2020-05-18 04:49:57 +00:00
public function testFontSizeToPixels($expectedResult, ...$args): void
2015-05-17 13:00:02 +00:00
{
$result = Font::fontSizeToPixels(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
public function providerFontSizeToPixels()
{
return require 'tests/data/Shared/FontSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerInchSizeToPixels
*
* @param mixed $expectedResult
*/
2020-05-18 04:49:57 +00:00
public function testInchSizeToPixels($expectedResult, ...$args): void
2015-05-17 13:00:02 +00:00
{
$result = Font::inchSizeToPixels(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
public function providerInchSizeToPixels()
{
return require 'tests/data/Shared/InchSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerCentimeterSizeToPixels
*
* @param mixed $expectedResult
*/
2020-05-18 04:49:57 +00:00
public function testCentimeterSizeToPixels($expectedResult, ...$args): void
2015-05-17 13:00:02 +00:00
{
$result = Font::centimeterSizeToPixels(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
public function providerCentimeterSizeToPixels()
{
return require 'tests/data/Shared/CentimeterSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
}