TransitionTest.php 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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\Transition;
  19. /**
  20. * Test class for PhpPresentation
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Slide\Transition
  23. */
  24. class TransitionTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testSpeed()
  27. {
  28. $object = new Transition();
  29. $this->assertNull($object->getSpeed());
  30. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed());
  31. $this->assertEquals(Transition::SPEED_MEDIUM, $object->getSpeed());
  32. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed(Transition::SPEED_FAST));
  33. $this->assertEquals(Transition::SPEED_FAST, $object->getSpeed());
  34. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setSpeed(rand(1, 1000)));
  35. $this->assertNull($object->getSpeed());
  36. }
  37. public function testManualTrigger()
  38. {
  39. $object = new Transition();
  40. $this->assertFalse($object->hasManualTrigger());
  41. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger());
  42. $this->assertFalse($object->hasManualTrigger());
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(true));
  44. $this->assertTrue($object->hasManualTrigger());
  45. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(null));
  46. $this->assertTrue($object->hasManualTrigger());
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(false));
  48. $this->assertFalse($object->hasManualTrigger());
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setManualTrigger(null));
  50. $this->assertFalse($object->hasManualTrigger());
  51. }
  52. public function testTimeTrigger()
  53. {
  54. $object = new Transition();
  55. $this->assertFalse($object->hasTimeTrigger());
  56. $this->assertNull($object->getAdvanceTimeTrigger());
  57. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger());
  58. $this->assertFalse($object->hasTimeTrigger());
  59. $this->assertNull($object->getAdvanceTimeTrigger());
  60. $value = rand(1, 1000);
  61. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(true, $value));
  62. $this->assertTrue($object->hasTimeTrigger());
  63. $this->assertEquals($value, $object->getAdvanceTimeTrigger());
  64. $value = rand(1, 1000);
  65. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(null, $value));
  66. $this->assertTrue($object->hasTimeTrigger());
  67. $this->assertEquals($value, $object->getAdvanceTimeTrigger());
  68. $value = rand(1, 1000);
  69. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(false, $value));
  70. $this->assertFalse($object->hasTimeTrigger());
  71. $this->assertNull($object->getAdvanceTimeTrigger());
  72. $value = rand(1, 1000);
  73. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTimeTrigger(null, $value));
  74. $this->assertFalse($object->hasTimeTrigger());
  75. $this->assertNull($object->getAdvanceTimeTrigger());
  76. }
  77. public function testTransitionType()
  78. {
  79. $object = new Transition();
  80. $this->assertNull($object->getTransitionType());
  81. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType());
  82. $this->assertNull($object->getTransitionType());
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Transition', $object->setTransitionType(Transition::TRANSITION_RANDOM));
  84. $this->assertEquals(Transition::TRANSITION_RANDOM, $object->getTransitionType());
  85. }
  86. }