View3DTest.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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\Chart;
  18. use PhpOffice\PhpPresentation\Shape\Chart\View3D;
  19. /**
  20. * Test class for View3D element
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Chart\View3D
  23. */
  24. class View3DTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testDepthPercent()
  27. {
  28. $object = new View3D();
  29. $value = rand(20, 20000);
  30. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent());
  31. $this->assertEquals(100, $object->getDepthPercent());
  32. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setDepthPercent($value));
  33. $this->assertEquals($value, $object->getDepthPercent());
  34. }
  35. public function testHashIndex()
  36. {
  37. $object = new View3D();
  38. $value = rand(1, 100);
  39. $this->assertEmpty($object->getHashIndex());
  40. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHashIndex($value));
  41. $this->assertEquals($value, $object->getHashIndex());
  42. }
  43. public function testHeightPercent()
  44. {
  45. $object = new View3D();
  46. $value = rand(5, 500);
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent());
  48. $this->assertEquals(100, $object->getHeightPercent());
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setHeightPercent($value));
  50. $this->assertEquals($value, $object->getHeightPercent());
  51. }
  52. public function testPerspective()
  53. {
  54. $object = new View3D();
  55. $value = rand(0, 100);
  56. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective());
  57. $this->assertEquals(30, $object->getPerspective());
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setPerspective($value));
  59. $this->assertEquals($value, $object->getPerspective());
  60. }
  61. public function testRightAngleAxes()
  62. {
  63. $object = new View3D();
  64. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes());
  65. $this->assertTrue($object->hasRightAngleAxes());
  66. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(true));
  67. $this->assertTrue($object->hasRightAngleAxes());
  68. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRightAngleAxes(false));
  69. $this->assertFalse($object->hasRightAngleAxes());
  70. }
  71. public function testRotationX()
  72. {
  73. $object = new View3D();
  74. $value = rand(-90, 90);
  75. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX());
  76. $this->assertEquals(0, $object->getRotationX());
  77. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationX($value));
  78. $this->assertEquals($value, $object->getRotationX());
  79. }
  80. public function testRotationY()
  81. {
  82. $object = new View3D();
  83. $value = rand(-90, 90);
  84. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY());
  85. $this->assertEquals(0, $object->getRotationY());
  86. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\View3D', $object->setRotationY($value));
  87. $this->assertEquals($value, $object->getRotationY());
  88. }
  89. }