PlaceholderTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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;
  18. use PhpOffice\PhpPresentation\Shape\Placeholder;
  19. /**
  20. * Test class for Table element
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Table
  23. */
  24. class PlaceholderTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testConstruct()
  27. {
  28. $object = new Placeholder(Placeholder::PH_TYPE_BODY);
  29. $this->assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
  30. $this->assertNull($object->getIdx());
  31. }
  32. public function testIdx()
  33. {
  34. $value = rand(0, 100);
  35. $object = new Placeholder(Placeholder::PH_TYPE_BODY);
  36. $this->assertNull($object->getIdx());
  37. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setIdx($value));
  38. $this->assertEquals($value, $object->getIdx());
  39. }
  40. public function testType()
  41. {
  42. $rcPlaceholder = new \ReflectionClass('PhpOffice\PhpPresentation\Shape\Placeholder');
  43. $arrayConstants = $rcPlaceholder->getConstants();
  44. $value = array_rand($arrayConstants);
  45. $object = new Placeholder(Placeholder::PH_TYPE_BODY);
  46. $this->assertEquals(Placeholder::PH_TYPE_BODY, $object->getType());
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Placeholder', $object->setType($value));
  48. $this->assertEquals($value, $object->getType());
  49. }
  50. }