TableTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\Table;
  19. /**
  20. * Test class for Table element
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Shape\Table
  23. */
  24. class TableTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testConstruct()
  27. {
  28. $object = new Table();
  29. $this->assertEmpty($object->getRows());
  30. $this->assertFalse($object->isResizeProportional());
  31. }
  32. public function testNumColums()
  33. {
  34. $value = rand(1, 100);
  35. $object = new Table();
  36. $this->assertEquals(1, $object->getNumColumns());
  37. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table', $object->setNumColumns($value));
  38. $this->assertEquals($value, $object->getNumColumns());
  39. }
  40. public function testRows()
  41. {
  42. $object = new Table();
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->createRow());
  44. $this->assertCount(1, $object->getRows());
  45. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Table\\Row', $object->getRow(0));
  46. $this->assertNull($object->getRow(1, true));
  47. }
  48. /**
  49. * @expectedException \Exception
  50. * expectedExceptionMessage Row number out of bounds.
  51. */
  52. public function testGetRowException()
  53. {
  54. $object = new Table();
  55. $object->getRow();
  56. }
  57. public function testHashCode()
  58. {
  59. $object = new Table();
  60. $this->assertEquals(md5(get_class($object)), $object->getHashCode());
  61. $row = $object->createRow();
  62. $this->assertEquals(md5($row->getHashCode().get_class($object)), $object->getHashCode());
  63. }
  64. }