PhpSpreadsheet/tests/PhpSpreadsheetTests/Shared/FontTest.php

86 lines
2.3 KiB
PHP
Raw Normal View History

<?php
namespace PhpSpreadsheetTests\Shared;
use PhpSpreadsheet\Shared\Font;
2016-03-22 14:35:50 +00:00
class FontTest extends \PHPUnit_Framework_TestCase
{
2015-05-17 13:00:02 +00:00
public function testGetAutoSizeMethod()
{
$expectedResult = Font::AUTOSIZE_METHOD_APPROX;
$result = Font::getAutoSizeMethod();
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
2015-05-17 13:00:02 +00:00
public function testSetAutoSizeMethod()
{
$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);
2015-05-17 13:00:02 +00:00
$this->assertTrue($result);
}
}
public function testSetAutoSizeMethodWithInvalidValue()
2015-05-17 13:00:02 +00:00
{
$unsupportedAutosizeMethod = 'guess';
$result = Font::setAutoSizeMethod($unsupportedAutosizeMethod);
2015-05-17 13:00:02 +00:00
$this->assertFalse($result);
}
/**
* @dataProvider providerFontSizeToPixels
*/
2015-05-17 13:00:02 +00:00
public function testFontSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([Font::class, 'fontSizeToPixels'], $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerFontSizeToPixels()
{
return require 'data/Shared/FontSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerInchSizeToPixels
*/
2015-05-17 13:00:02 +00:00
public function testInchSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([Font::class, 'inchSizeToPixels'], $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerInchSizeToPixels()
{
return require 'data/Shared/InchSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
/**
* @dataProvider providerCentimeterSizeToPixels
*/
2015-05-17 13:00:02 +00:00
public function testCentimeterSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array([Font::class, 'centimeterSizeToPixels'], $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerCentimeterSizeToPixels()
{
return require 'data/Shared/CentimeterSizeToPixels.php';
2015-05-17 13:00:02 +00:00
}
}