PlotAreaTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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;
  19. use PhpOffice\PhpPresentation\Shape\Chart\Axis;
  20. use PhpOffice\PhpPresentation\Shape\Chart\PlotArea;
  21. use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D;
  22. /**
  23. * Test class for PlotArea element
  24. *
  25. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Chart\PlotArea
  26. */
  27. class PlotAreaTest extends \PHPUnit_Framework_TestCase
  28. {
  29. public function testConstruct()
  30. {
  31. $object = new PlotArea();
  32. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->getAxisX());
  33. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->getAxisY());
  34. }
  35. public function testHashIndex()
  36. {
  37. $object = new PlotArea();
  38. $value = rand(1, 100);
  39. $this->assertEmpty($object->getHashIndex());
  40. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setHashIndex($value));
  41. $this->assertEquals($value, $object->getHashIndex());
  42. }
  43. public function testHeight()
  44. {
  45. $object = new PlotArea();
  46. $value = rand(0, 100);
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setHeight());
  48. $this->assertEquals(0, $object->getHeight());
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setHeight($value));
  50. $this->assertEquals($value, $object->getHeight());
  51. }
  52. public function testOffsetX()
  53. {
  54. $object = new PlotArea();
  55. $value = rand(0, 100);
  56. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setOffsetX());
  57. $this->assertEquals(0, $object->getOffsetX());
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setOffsetX($value));
  59. $this->assertEquals($value, $object->getOffsetX());
  60. }
  61. public function testOffsetY()
  62. {
  63. $object = new PlotArea();
  64. $value = rand(0, 100);
  65. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setOffsetY());
  66. $this->assertEquals(0, $object->getOffsetY());
  67. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setOffsetY($value));
  68. $this->assertEquals($value, $object->getOffsetY());
  69. }
  70. public function testType()
  71. {
  72. $object = new PlotArea();
  73. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setType(new Bar3D()));
  74. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\AbstractType', $object->getType());
  75. }
  76. /**
  77. * @expectedException \Exception
  78. * @expectedExceptionMessage Chart type has not been set.
  79. */
  80. public function testTypeException()
  81. {
  82. $object = new PlotArea();
  83. $object->getType();
  84. }
  85. public function testWidth()
  86. {
  87. $object = new PlotArea();
  88. $value = rand(0, 100);
  89. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setWidth());
  90. $this->assertEquals(0, $object->getWidth());
  91. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\PlotArea', $object->setWidth($value));
  92. $this->assertEquals($value, $object->getWidth());
  93. }
  94. }