SlideMasterTest.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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;
  18. use PhpOffice\PhpPresentation\Slide\SlideMaster;
  19. /**
  20. * Test class for PhpPresentation
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\Slide\SlideMaster
  23. */
  24. class SlideMasterTest extends \PHPUnit_Framework_TestCase
  25. {
  26. public function testBase()
  27. {
  28. $object = new SlideMaster();
  29. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\AbstractSlide', $object);
  30. $this->assertNull($object->getParent());
  31. $this->assertInstanceOf('\\ArrayObject', $object->getShapeCollection());
  32. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\ColorMap', $object->colorMap);
  33. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Color', $object->getBackground());
  34. $this->assertEquals('FFFFFF', $object->getBackground()->getColor()->getRGB());
  35. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
  36. }
  37. public function testLayout()
  38. {
  39. $object = new SlideMaster();
  40. // Mock Post
  41. $mockSlideLayout = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Slide\SlideLayout', array($object));
  42. $this->assertEmpty($object->getAllSlideLayouts());
  43. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideLayout', $object->createSlideLayout());
  44. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideLayout', $object->addSlideLayout($mockSlideLayout));
  45. $this->assertCount(2, $object->getAllSlideLayouts());
  46. }
  47. public function testSchemeColors()
  48. {
  49. // Mock Pre
  50. $mockSchemeColorAccent1 = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Style\SchemeColor');
  51. $mockSchemeColorAccent1->setValue('accent1');
  52. $mockSchemeColorAccent1->setRGB('ABCDEF');
  53. $mockSchemeColorNew = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Style\SchemeColor');
  54. $mockSchemeColorNew->setValue('new');
  55. $mockSchemeColorNew->setRGB('ABCDEF');
  56. $object = new SlideMaster();
  57. $this->assertInternalType('array', $object->getAllSchemeColors());
  58. $this->assertCount(12, $object->getAllSchemeColors());
  59. // Add idem value
  60. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorAccent1));
  61. $this->assertCount(12, $object->getAllSchemeColors());
  62. // Add new value
  63. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->addSchemeColor($mockSchemeColorNew));
  64. $this->assertCount(13, $object->getAllSchemeColors());
  65. }
  66. public function testTextStyles()
  67. {
  68. // Mock Pre
  69. $mockTextStyle = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Style\TextStyle');
  70. $object = new SlideMaster();
  71. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
  72. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\SlideMaster', $object->setTextStyles($mockTextStyle));
  73. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\TextStyle', $object->getTextStyles());
  74. }
  75. }