BulletTest.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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\Bullet;
  19. use PhpOffice\PhpPresentation\Style\Color;
  20. /**
  21. * Test class for PhpPresentation
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\PhpPresentation
  24. */
  25. class BulletTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $object = new Bullet();
  33. $this->assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
  34. $this->assertEquals('Calibri', $object->getBulletFont());
  35. $this->assertEquals('-', $object->getBulletChar());
  36. $this->assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
  37. $this->assertEquals(1, $object->getBulletNumericStartAt());
  38. }
  39. /**
  40. * Test get/set bullet char
  41. */
  42. public function testSetGetBulletChar()
  43. {
  44. $object = new Bullet();
  45. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar());
  46. $this->assertEquals('-', $object->getBulletChar());
  47. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletChar('a'));
  48. $this->assertEquals('a', $object->getBulletChar());
  49. }
  50. /**
  51. * Test get/set bullet color
  52. */
  53. public function testSetGetBulletColor()
  54. {
  55. $object = new Bullet();
  56. $expectedARGB = '01234567';
  57. // default
  58. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
  59. $this->assertEquals(Color::COLOR_BLACK, $object->getBulletColor()->getARGB());
  60. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletColor(new Color($expectedARGB)));
  61. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getBulletColor());
  62. $this->assertEquals($expectedARGB, $object->getBulletColor()->getARGB());
  63. }
  64. /**
  65. * Test get/set bullet font
  66. */
  67. public function testSetGetBulletFont()
  68. {
  69. $object = new Bullet();
  70. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont());
  71. $this->assertEquals('Calibri', $object->getBulletFont());
  72. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont(''));
  73. $this->assertEquals('Calibri', $object->getBulletFont());
  74. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletFont('Arial'));
  75. $this->assertEquals('Arial', $object->getBulletFont());
  76. }
  77. /**
  78. * Test get/set bullet numeric start at
  79. */
  80. public function testSetGetBulletNumericStartAt()
  81. {
  82. $object = new Bullet();
  83. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt());
  84. $this->assertEquals(1, $object->getBulletNumericStartAt());
  85. $value = rand(1, 100);
  86. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStartAt($value));
  87. $this->assertEquals($value, $object->getBulletNumericStartAt());
  88. }
  89. /**
  90. * Test get/set bullet numeric style
  91. */
  92. public function testSetGetBulletNumericStyle()
  93. {
  94. $object = new Bullet();
  95. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle());
  96. $this->assertEquals(Bullet::NUMERIC_DEFAULT, $object->getBulletNumericStyle());
  97. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletNumericStyle(Bullet::NUMERIC_ALPHALCPARENBOTH));
  98. $this->assertEquals(Bullet::NUMERIC_ALPHALCPARENBOTH, $object->getBulletNumericStyle());
  99. }
  100. /**
  101. * Test get/set bullet type
  102. */
  103. public function testSetGetBulletType()
  104. {
  105. $object = new Bullet();
  106. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType());
  107. $this->assertEquals(Bullet::TYPE_NONE, $object->getBulletType());
  108. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Bullet', $object->setBulletType(Bullet::TYPE_BULLET));
  109. $this->assertEquals(Bullet::TYPE_BULLET, $object->getBulletType());
  110. }
  111. /**
  112. * Test get/set has index
  113. */
  114. public function testSetGetHashIndex()
  115. {
  116. $object = new Bullet();
  117. $value = rand(1, 100);
  118. $object->setHashIndex($value);
  119. $this->assertEquals($value, $object->getHashIndex());
  120. }
  121. }