BorderTest.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\Color;
  20. /**
  21. * Test class for PhpPresentation
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  24. */
  25. class BorderTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Border();
  33. $this->assertEquals(1, $object->getLineWidth());
  34. $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
  35. $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
  36. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
  37. $this->assertEquals('FF000000', $object->getColor()->getARGB());
  38. }
  39. /**
  40. * Test get/set color
  41. */
  42. public function testSetGetColor()
  43. {
  44. $object = new Border();
  45. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor());
  46. $this->assertNull($object->getColor());
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setColor(new Color(COLOR::COLOR_BLUE)));
  48. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
  49. $this->assertEquals('FF0000FF', $object->getColor()->getARGB());
  50. }
  51. /**
  52. * Test get/set dash style
  53. */
  54. public function testSetGetDashStyle()
  55. {
  56. $object = new Border();
  57. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle());
  58. $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
  59. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(''));
  60. $this->assertEquals(Border::DASH_SOLID, $object->getDashStyle());
  61. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setDashStyle(BORDER::DASH_DASH));
  62. $this->assertEquals(Border::DASH_DASH, $object->getDashStyle());
  63. }
  64. /**
  65. * Test get/set hash index
  66. */
  67. public function testSetGetHashIndex()
  68. {
  69. $object = new Border();
  70. $value = rand(1, 100);
  71. $object->setHashIndex($value);
  72. $this->assertEquals($value, $object->getHashIndex());
  73. }
  74. /**
  75. * Test get/set line style
  76. */
  77. public function testSetGetLineStyle()
  78. {
  79. $object = new Border();
  80. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle());
  81. $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
  82. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(''));
  83. $this->assertEquals(Border::LINE_SINGLE, $object->getLineStyle());
  84. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineStyle(BORDER::LINE_DOUBLE));
  85. $this->assertEquals(Border::LINE_DOUBLE, $object->getLineStyle());
  86. }
  87. /**
  88. * Test get/set line width
  89. */
  90. public function testSetGetLineWidth()
  91. {
  92. $object = new Border();
  93. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth());
  94. $this->assertEquals(1, $object->getLineWidth());
  95. $value = rand(1, 100);
  96. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Border', $object->setLineWidth($value));
  97. $this->assertEquals($value, $object->getLineWidth());
  98. }
  99. }