FontTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class FontTest extends PHPUnit_Framework_TestCase
  4. {
  5. public function setUp()
  6. {
  7. if (!defined('PHPEXCEL_ROOT')) {
  8. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  9. }
  10. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  11. }
  12. public function testGetAutoSizeMethod()
  13. {
  14. $expectedResult = PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX;
  15. $result = call_user_func(array('PHPExcel_Shared_Font','getAutoSizeMethod'));
  16. $this->assertEquals($expectedResult, $result);
  17. }
  18. public function testSetAutoSizeMethod()
  19. {
  20. $autosizeMethodValues = array(
  21. PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT,
  22. PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
  23. );
  24. foreach($autosizeMethodValues as $autosizeMethodValue) {
  25. $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$autosizeMethodValue);
  26. $this->assertTrue($result);
  27. }
  28. }
  29. public function testSetAutoSizeMethodWithInvalidValue()
  30. {
  31. $unsupportedAutosizeMethod = 'guess';
  32. $result = call_user_func(array('PHPExcel_Shared_Font','setAutoSizeMethod'),$unsupportedAutosizeMethod);
  33. $this->assertFalse($result);
  34. }
  35. /**
  36. * @dataProvider providerFontSizeToPixels
  37. */
  38. public function testFontSizeToPixels()
  39. {
  40. $args = func_get_args();
  41. $expectedResult = array_pop($args);
  42. $result = call_user_func_array(array('PHPExcel_Shared_Font','fontSizeToPixels'),$args);
  43. $this->assertEquals($expectedResult, $result);
  44. }
  45. public function providerFontSizeToPixels()
  46. {
  47. return new testDataFileIterator('rawTestData/Shared/FontSizeToPixels.data');
  48. }
  49. /**
  50. * @dataProvider providerInchSizeToPixels
  51. */
  52. public function testInchSizeToPixels()
  53. {
  54. $args = func_get_args();
  55. $expectedResult = array_pop($args);
  56. $result = call_user_func_array(array('PHPExcel_Shared_Font','inchSizeToPixels'),$args);
  57. $this->assertEquals($expectedResult, $result);
  58. }
  59. public function providerInchSizeToPixels()
  60. {
  61. return new testDataFileIterator('rawTestData/Shared/InchSizeToPixels.data');
  62. }
  63. /**
  64. * @dataProvider providerCentimeterSizeToPixels
  65. */
  66. public function testCentimeterSizeToPixels()
  67. {
  68. $args = func_get_args();
  69. $expectedResult = array_pop($args);
  70. $result = call_user_func_array(array('PHPExcel_Shared_Font','centimeterSizeToPixels'),$args);
  71. $this->assertEquals($expectedResult, $result);
  72. }
  73. public function providerCentimeterSizeToPixels()
  74. {
  75. return new testDataFileIterator('rawTestData/Shared/CentimeterSizeToPixels.data');
  76. }
  77. }