PhpSpreadsheet/unitTests/Classes/src/Shared/FontTest.php

86 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2016-03-22 14:35:50 +00:00
namespace PHPExcel\Shared;
require_once 'testDataFileIterator.php';
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()
{
2016-03-22 14:19:00 +00:00
$expectedResult = \PHPExcel\Shared\Font::AUTOSIZE_METHOD_APPROX;
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\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 = array(
2016-03-22 14:19:00 +00:00
\PHPExcel\Shared\Font::AUTOSIZE_METHOD_EXACT,
\PHPExcel\Shared\Font::AUTOSIZE_METHOD_APPROX,
2015-05-17 13:00:02 +00:00
);
foreach ($autosizeMethodValues as $autosizeMethodValue) {
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\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';
2016-03-22 14:19:00 +00:00
$result = call_user_func(array('\PHPExcel\Shared\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);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Shared\Font','fontSizeToPixels'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerFontSizeToPixels()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Shared/FontSizeToPixels.data');
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);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Shared\Font','inchSizeToPixels'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerInchSizeToPixels()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Shared/InchSizeToPixels.data');
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);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Shared\Font','centimeterSizeToPixels'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
public function providerCentimeterSizeToPixels()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data');
2015-05-17 13:00:02 +00:00
}
}