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

94 lines
2.8 KiB
PHP
Raw Normal View History

<?php
require_once 'testDataFileIterator.php';
class FontTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
2015-05-17 13:00:02 +00:00
}
2015-05-17 13:00:02 +00:00
public function testGetAutoSizeMethod()
{
$expectedResult = PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX;
2015-05-17 13:00:02 +00:00
$result = call_user_func(array('PHPExcel_Shared_Font','getAutoSizeMethod'));
$this->assertEquals($expectedResult, $result);
}
2015-05-17 13:00:02 +00:00
public function testSetAutoSizeMethod()
{
$autosizeMethodValues = array(
PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT,
PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
);
foreach ($autosizeMethodValues as $autosizeMethodValue) {
2015-05-17 16:34:30 +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';
2015-05-17 16:34:30 +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);
2015-05-17 16:34:30 +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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Shared/FontSizeToPixels.data');
}
/**
* @dataProvider providerInchSizeToPixels
*/
2015-05-17 13:00:02 +00:00
public function testInchSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Shared/InchSizeToPixels.data');
}
/**
* @dataProvider providerCentimeterSizeToPixels
*/
2015-05-17 13:00:02 +00:00
public function testCentimeterSizeToPixels()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2015-05-17 16:34:30 +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()
{
2015-05-17 13:00:02 +00:00
return new testDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data');
}
}