FontTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. }