PresentationPropertiesTest.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\PresentationProperties;
  19. /**
  20. * Test class for DocumentProperties
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\PresentationProperties
  23. */
  24. class PresentationPropertiesTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testCommentVisible()
  27. {
  28. $object = new PresentationProperties();
  29. $this->assertFalse($object->isCommentVisible());
  30. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setCommentVisible('AAAA'));
  31. $this->assertFalse($object->isCommentVisible());
  32. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setCommentVisible(true));
  33. $this->assertTrue($object->isCommentVisible());
  34. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setCommentVisible(false));
  35. $this->assertFalse($object->isCommentVisible());
  36. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setCommentVisible());
  37. $this->assertFalse($object->isCommentVisible());
  38. }
  39. public function testLoopUntilEsc()
  40. {
  41. $object = new PresentationProperties();
  42. $this->assertFalse($object->isLoopContinuouslyUntilEsc());
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLoopContinuouslyUntilEsc('AAAA'));
  44. $this->assertFalse($object->isLoopContinuouslyUntilEsc());
  45. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLoopContinuouslyUntilEsc(true));
  46. $this->assertTrue($object->isLoopContinuouslyUntilEsc());
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLoopContinuouslyUntilEsc(false));
  48. $this->assertFalse($object->isLoopContinuouslyUntilEsc());
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLoopContinuouslyUntilEsc());
  50. $this->assertFalse($object->isLoopContinuouslyUntilEsc());
  51. }
  52. public function testLastView()
  53. {
  54. $object = new PresentationProperties();
  55. $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
  56. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLastView('AAAA'));
  57. $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLastView(PresentationProperties::VIEW_OUTLINE));
  59. $this->assertEquals(PresentationProperties::VIEW_OUTLINE, $object->getLastView());
  60. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setLastView());
  61. $this->assertEquals(PresentationProperties::VIEW_SLIDE, $object->getLastView());
  62. }
  63. public function testMarkAsFinal()
  64. {
  65. $object = new PresentationProperties();
  66. $this->assertFalse($object->isMarkedAsFinal());
  67. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal('AAAA'));
  68. $this->assertFalse($object->isMarkedAsFinal());
  69. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal(true));
  70. $this->assertTrue($object->isMarkedAsFinal());
  71. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal(false));
  72. $this->assertFalse($object->isMarkedAsFinal());
  73. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->markAsFinal());
  74. $this->assertTrue($object->isMarkedAsFinal());
  75. }
  76. public function testThumbnail()
  77. {
  78. $imagePath = PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png';
  79. $object = new PresentationProperties();
  80. $this->assertNull($object->getThumbnailPath());
  81. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setThumbnailPath('AAAA'));
  82. $this->assertNull($object->getThumbnailPath());
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setThumbnailPath());
  84. $this->assertNull($object->getThumbnailPath());
  85. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setThumbnailPath($imagePath));
  86. $this->assertEquals($imagePath, $object->getThumbnailPath());
  87. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setThumbnailPath());
  88. $this->assertEquals($imagePath, $object->getThumbnailPath());
  89. }
  90. public function testZoom()
  91. {
  92. $object = new PresentationProperties();
  93. $this->assertEquals(1, $object->getZoom());
  94. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setZoom('AAAA'));
  95. $this->assertEquals(1, $object->getZoom());
  96. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setZoom(2.3));
  97. $this->assertEquals(2.3, $object->getZoom());
  98. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PresentationProperties', $object->setZoom());
  99. $this->assertEquals(1, $object->getZoom());
  100. }
  101. }