RunTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * This file is part of PHPPresentation - A pure PHP library for reading and writing
  4. * presentations documents.
  5. *
  6. * PHPPresentation is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
  12. *
  13. * @copyright 2009-2015 PHPPresentation contributors
  14. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  15. * @link https://github.com/PHPOffice/PHPPresentation
  16. */
  17. namespace PhpOffice\PhpPresentation\Tests\Shape\RichText;
  18. use PhpOffice\PhpPresentation\Shape\RichText\Run;
  19. use PhpOffice\PhpPresentation\Style\Font;
  20. /**
  21. * Test class for Run element
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\RichText\Run
  24. */
  25. class RunTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test can read
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Run();
  33. $this->assertEquals('', $object->getText());
  34. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
  35. $object = new Run('BBB');
  36. $this->assertEquals('BBB', $object->getText());
  37. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
  38. }
  39. public function testFont()
  40. {
  41. $object = new Run();
  42. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setFont(new Font()));
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
  44. }
  45. public function testLanguage()
  46. {
  47. $object = new Run();
  48. $this->assertNull($object->getLanguage());
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setLanguage('en-US'));
  50. $this->assertEquals('en-US', $object->getLanguage());
  51. }
  52. public function testText()
  53. {
  54. $object = new Run();
  55. $this->assertEquals('', $object->getText());
  56. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText());
  57. $this->assertEquals('', $object->getText());
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->setText('AAA'));
  59. $this->assertEquals('AAA', $object->getText());
  60. $object = new Run('BBB');
  61. $this->assertEquals('BBB', $object->getText());
  62. }
  63. /**
  64. * Test get/set hash index
  65. */
  66. public function testHashCode()
  67. {
  68. $object = new Run();
  69. $this->assertEquals(md5($object->getFont()->getHashCode().get_class($object)), $object->getHashCode());
  70. }
  71. }