CommentTest.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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;
  18. use PhpOffice\PhpPresentation\Shape\Comment;
  19. /**
  20. * Test class for Chart element
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Comment
  23. */
  24. class CommentTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testConstruct()
  27. {
  28. $object = new Comment();
  29. $this->assertNull($object->getAuthor());
  30. $this->assertNull($object->getText());
  31. $this->assertInternalType('int', $object->getDate());
  32. $this->assertNull($object->getHeight());
  33. $this->assertNull($object->getWidth());
  34. }
  35. public function testGetSetAuthor()
  36. {
  37. $object = new Comment();
  38. $oStub = $this->getMockBuilder('PhpOffice\PhpPresentation\Shape\Comment\Author')->getMock();
  39. $this->assertNull($object->getAuthor());
  40. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setAuthor($oStub));
  41. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment\\Author', $object->getAuthor());
  42. }
  43. public function testGetSetDate()
  44. {
  45. $expectedDate = time();
  46. $object = new Comment();
  47. $this->assertInternalType('int', $object->getDate());
  48. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setDate($expectedDate));
  49. $this->assertEquals($expectedDate, $object->getDate());
  50. $this->assertInternalType('int', $object->getDate());
  51. }
  52. public function testGetSetText()
  53. {
  54. $expectedText = 'AABBCCDD';
  55. $object = new Comment();
  56. $this->assertNull($object->getText());
  57. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setText($expectedText));
  58. $this->assertEquals($expectedText, $object->getText());
  59. }
  60. public function testGetSetHeightAndWidtg()
  61. {
  62. $object = new Comment();
  63. $this->assertNull($object->getHeight());
  64. $this->assertNull($object->getWidth());
  65. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setHeight(1));
  66. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Comment', $object->setWidth(1));
  67. $this->assertNull($object->getHeight());
  68. $this->assertNull($object->getWidth());
  69. }
  70. }