NoteTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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;
  18. use PhpOffice\PhpPresentation\PhpPresentation;
  19. use PhpOffice\PhpPresentation\Shape\RichText;
  20. use PhpOffice\PhpPresentation\Slide\Note;
  21. /**
  22. * Test class for PhpPresentation
  23. *
  24. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  25. */
  26. class NoteTest extends \PHPUnit_Framework_TestCase
  27. {
  28. public function testParent()
  29. {
  30. $object = new Note();
  31. $this->assertNull($object->getParent());
  32. $oPhpPresentation = new PhpPresentation();
  33. $oSlide = $oPhpPresentation->createSlide();
  34. $oSlide->setNote($object);
  35. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
  36. }
  37. public function testExtent()
  38. {
  39. $object = new Note();
  40. $this->assertNotNull($object->getExtentX());
  41. $object = new Note();
  42. $this->assertNotNull($object->getExtentY());
  43. }
  44. public function testHashCode()
  45. {
  46. $object = new Note();
  47. $this->assertInternalType('string', $object->getHashCode());
  48. }
  49. public function testOffset()
  50. {
  51. $object = new Note();
  52. $this->assertNotNull($object->getOffsetX());
  53. $object = new Note();
  54. $this->assertNotNull($object->getOffsetY());
  55. }
  56. public function testShape()
  57. {
  58. $object = new Note();
  59. $this->assertEquals(0, $object->getShapeCollection()->count());
  60. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->createRichTextShape());
  61. $this->assertEquals(1, $object->getShapeCollection()->count());
  62. $oRichText = new RichText();
  63. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $object->addShape($oRichText));
  64. $this->assertEquals(2, $object->getShapeCollection()->count());
  65. }
  66. /**
  67. * Test get/set hash index
  68. */
  69. public function testSetGetHashIndex()
  70. {
  71. $object = new Note();
  72. $value = rand(1, 100);
  73. $this->assertNull($object->getHashIndex());
  74. $object->setHashIndex($value);
  75. $this->assertEquals($value, $object->getHashIndex());
  76. }
  77. }