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