SlideTest.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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\Slide;
  19. use PhpOffice\PhpPresentation\Slide\Transition;
  20. use PhpOffice\PhpPresentation\PhpPresentation;
  21. /**
  22. * Test class for PhpPresentation
  23. *
  24. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  25. */
  26. class SlideTest extends \PHPUnit_Framework_TestCase
  27. {
  28. public function testExtents()
  29. {
  30. $object = new Slide();
  31. $this->assertNotNull($object->getExtentX());
  32. $object = new Slide();
  33. $this->assertNotNull($object->getExtentY());
  34. }
  35. public function testOffset()
  36. {
  37. $object = new Slide();
  38. $this->assertNotNull($object->getOffsetX());
  39. $object = new Slide();
  40. $this->assertNotNull($object->getOffsetY());
  41. }
  42. public function testParent()
  43. {
  44. $object = new Slide();
  45. $this->assertNull($object->getParent());
  46. $oPhpPresentation = new PhpPresentation();
  47. $object = new Slide($oPhpPresentation);
  48. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getParent());
  49. }
  50. public function testSlideMasterId()
  51. {
  52. $value = rand(1, 100);
  53. $object = new Slide();
  54. $this->assertEquals(1, $object->getSlideMasterId());
  55. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setSlideMasterId());
  56. $this->assertEquals(1, $object->getSlideMasterId());
  57. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setSlideMasterId($value));
  58. $this->assertEquals($value, $object->getSlideMasterId());
  59. }
  60. public function testAnimations()
  61. {
  62. $oStub = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Slide\Animation');
  63. $object = new Slide();
  64. $this->assertInternalType('array', $object->getAnimations());
  65. $this->assertCount(0, $object->getAnimations());
  66. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->addAnimation($oStub));
  67. $this->assertInternalType('array', $object->getAnimations());
  68. $this->assertCount(1, $object->getAnimations());
  69. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setAnimations());
  70. $this->assertInternalType('array', $object->getAnimations());
  71. $this->assertCount(0, $object->getAnimations());
  72. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setAnimations(array($oStub)));
  73. $this->assertInternalType('array', $object->getAnimations());
  74. $this->assertCount(1, $object->getAnimations());
  75. }
  76. public function testBackground()
  77. {
  78. $oStub = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Slide\AbstractBackground');
  79. $object = new Slide();
  80. $this->assertNull($object->getBackground());
  81. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setBackground($oStub));
  82. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractBackground', $object->getBackground());
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setBackground());
  84. $this->assertNull($object->getBackground());
  85. }
  86. public function testGroup()
  87. {
  88. $object = new Slide();
  89. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Group', $object->createGroup());
  90. }
  91. public function testName()
  92. {
  93. $object = new Slide();
  94. $this->assertNull($object->getName());
  95. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setName('AAAA'));
  96. $this->assertEquals('AAAA', $object->getName());
  97. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setName());
  98. $this->assertNull($object->getName());
  99. }
  100. public function testTransition()
  101. {
  102. $object = new Slide();
  103. $oTransition = new Transition();
  104. $this->assertNull($object->getTransition());
  105. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setTransition());
  106. $this->assertNull($object->getTransition());
  107. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setTransition($oTransition));
  108. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->getTransition());
  109. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setTransition(null));
  110. $this->assertNull($object->getTransition());
  111. }
  112. public function testVisible()
  113. {
  114. $object = new Slide();
  115. $this->assertTrue($object->isVisible());
  116. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setIsVisible(false));
  117. $this->assertFalse($object->isVisible());
  118. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->setIsVisible());
  119. $this->assertTrue($object->isVisible());
  120. }
  121. }