FillTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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\Color;
  19. use PhpOffice\PhpPresentation\Style\Fill;
  20. /**
  21. * Test class for PhpPresentation
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  24. */
  25. class FillTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Fill();
  33. $this->assertEquals(Fill::FILL_NONE, $object->getFillType());
  34. $this->assertEquals(0, $object->getRotation());
  35. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getStartColor());
  36. $this->assertEquals(Color::COLOR_WHITE, $object->getStartColor()->getARGB());
  37. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getEndColor());
  38. $this->assertEquals(Color::COLOR_BLACK, $object->getEndColor()->getARGB());
  39. }
  40. /**
  41. * Test get/set end color
  42. */
  43. public function testSetGetEndColor()
  44. {
  45. $object = new Fill();
  46. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setEndColor());
  47. $this->assertNull($object->getEndColor());
  48. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setEndColor(new Color(COLOR::COLOR_BLUE)));
  49. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getEndColor());
  50. $this->assertEquals(COLOR::COLOR_BLUE, $object->getEndColor()->getARGB());
  51. }
  52. /**
  53. * Test get/set fill type
  54. */
  55. public function testSetGetFillType()
  56. {
  57. $object = new Fill();
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setFillType());
  59. $this->assertEquals(Fill::FILL_NONE, $object->getFillType());
  60. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setFillType(Fill::FILL_GRADIENT_LINEAR));
  61. $this->assertEquals(Fill::FILL_GRADIENT_LINEAR, $object->getFillType());
  62. }
  63. /**
  64. * Test get/set rotation
  65. */
  66. public function testSetGetRotation()
  67. {
  68. $object = new Fill();
  69. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setRotation());
  70. $this->assertEquals(0, $object->getRotation());
  71. $value = rand(1, 100);
  72. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setRotation($value));
  73. $this->assertEquals($value, $object->getRotation());
  74. }
  75. /**
  76. * Test get/set start color
  77. */
  78. public function testSetGetStartColor()
  79. {
  80. $object = new Fill();
  81. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setStartColor());
  82. $this->assertNull($object->getStartColor());
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Fill', $object->setStartColor(new Color(COLOR::COLOR_BLUE)));
  84. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getStartColor());
  85. $this->assertEquals(COLOR::COLOR_BLUE, $object->getStartColor()->getARGB());
  86. }
  87. /**
  88. * Test get/set hash index
  89. */
  90. public function testSetGetHashIndex()
  91. {
  92. $object = new Fill();
  93. $value = rand(1, 100);
  94. $object->setHashIndex($value);
  95. $this->assertEquals($value, $object->getHashIndex());
  96. }
  97. }