BordersTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\Style;
  18. use PhpOffice\PhpPresentation\Style\Border;
  19. use PhpOffice\PhpPresentation\Style\Borders;
  20. /**
  21. * Test class for PhpPresentation
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  24. */
  25. class BordersTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Borders();
  33. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getBottom());
  34. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getLeft());
  35. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getRight());
  36. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getTop());
  37. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalDown());
  38. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->getDiagonalUp());
  39. $this->assertEquals(Border::LINE_NONE, $object->getDiagonalDown()->getLineStyle());
  40. $this->assertEquals(Border::LINE_NONE, $object->getDiagonalUp()->getLineStyle());
  41. }
  42. /**
  43. * Test get/set hash index
  44. */
  45. public function testSetGetHashIndex()
  46. {
  47. $object = new Borders();
  48. $value = rand(1, 100);
  49. $object->setHashIndex($value);
  50. $this->assertEquals($value, $object->getHashIndex());
  51. }
  52. /**
  53. * Test get/set hash code
  54. */
  55. public function testGetHashCode()
  56. {
  57. $object = new Borders();
  58. $this->assertEquals(
  59. md5(
  60. $object->getLeft()->getHashCode() .
  61. $object->getRight()->getHashCode() .
  62. $object->getTop()->getHashCode() .
  63. $object->getBottom()->getHashCode() .
  64. $object->getDiagonalUp()->getHashCode() .
  65. $object->getDiagonalDown()->getHashCode() .
  66. get_class($object)
  67. ),
  68. $object->getHashCode()
  69. );
  70. }
  71. }