ShadowTest.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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\Shadow;
  20. /**
  21. * Test class for PhpPresentation
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  24. */
  25. class ShadowTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Shadow();
  33. $this->assertFalse($object->isVisible());
  34. $this->assertEquals(6, $object->getBlurRadius());
  35. $this->assertEquals(2, $object->getDistance());
  36. $this->assertEquals(0, $object->getDirection());
  37. $this->assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
  38. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
  39. $this->assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
  40. $this->assertEquals(50, $object->getAlpha());
  41. }
  42. /**
  43. * Test get/set alignment
  44. */
  45. public function testSetGetAlignment()
  46. {
  47. $object = new Shadow();
  48. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setAlignment());
  49. $this->assertEquals(Shadow::SHADOW_BOTTOM_RIGHT, $object->getAlignment());
  50. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setAlignment(Shadow::SHADOW_CENTER));
  51. $this->assertEquals(Shadow::SHADOW_CENTER, $object->getAlignment());
  52. }
  53. /**
  54. * Test get/set alpha
  55. */
  56. public function testSetGetAlpha()
  57. {
  58. $object = new Shadow();
  59. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setAlpha());
  60. $this->assertEquals(0, $object->getAlpha());
  61. $value = rand(1, 100);
  62. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setAlpha($value));
  63. $this->assertEquals($value, $object->getAlpha());
  64. }
  65. /**
  66. * Test get/set blur radius
  67. */
  68. public function testSetGetBlurRadius()
  69. {
  70. $object = new Shadow();
  71. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setBlurRadius());
  72. $this->assertEquals(6, $object->getBlurRadius());
  73. $value = rand(1, 100);
  74. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setBlurRadius($value));
  75. $this->assertEquals($value, $object->getBlurRadius());
  76. }
  77. /**
  78. * Test get/set color
  79. */
  80. public function testSetGetColor()
  81. {
  82. $object = new Shadow();
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setColor());
  84. $this->assertNull($object->getColor());
  85. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setColor(new Color(Color::COLOR_BLUE)));
  86. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
  87. $this->assertEquals(Color::COLOR_BLUE, $object->getColor()->getARGB());
  88. }
  89. /**
  90. * Test get/set direction
  91. */
  92. public function testSetGetDirection()
  93. {
  94. $object = new Shadow();
  95. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setDirection());
  96. $this->assertEquals(0, $object->getDirection());
  97. $value = rand(1, 100);
  98. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setDirection($value));
  99. $this->assertEquals($value, $object->getDirection());
  100. }
  101. /**
  102. * Test get/set distance
  103. */
  104. public function testSetGetDistance()
  105. {
  106. $object = new Shadow();
  107. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setDistance());
  108. $this->assertEquals(2, $object->getDistance());
  109. $value = rand(1, 100);
  110. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setDistance($value));
  111. $this->assertEquals($value, $object->getDistance());
  112. }
  113. /**
  114. * Test get/set hash index
  115. */
  116. public function testSetGetHashIndex()
  117. {
  118. $object = new Shadow();
  119. $value = rand(1, 100);
  120. $object->setHashIndex($value);
  121. $this->assertEquals($value, $object->getHashIndex());
  122. }
  123. /**
  124. * Test get/set visible
  125. */
  126. public function testSetIsVisible()
  127. {
  128. $object = new Shadow();
  129. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setVisible());
  130. $this->assertFalse($object->isVisible());
  131. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setVisible(false));
  132. $this->assertFalse($object->isVisible());
  133. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Shadow', $object->setVisible(true));
  134. $this->assertTrue($object->isVisible());
  135. }
  136. }