Skip to content

Commit 418a302

Browse files
author
Peter Lind
committed
adding test for allDrawings function in AbstractWriter
1 parent 312b7a2 commit 418a302

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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-2017 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\Writer;
19+
use PhpOffice\PhpPresentation\Writer;
20+
21+
/**
22+
* Mock class for AbstractWriter
23+
*
24+
*/
25+
class AbstractWriter extends Writer\AbstractWriter
26+
{
27+
/**
28+
* public wrapper for protected method
29+
*
30+
* @return \PhpOffice\PhpPresentation\Shape\AbstractDrawing[] All drawings in PhpPresentation
31+
* @throws \Exception
32+
*/
33+
public function allDrawings()
34+
{
35+
return parent::allDrawings();
36+
}
37+
}

tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717

1818
namespace PhpOffice\PhpPresentation\Tests\Writer;
19+
use PhpOffice\PhpPresentation\PhpPresentation;
20+
21+
require 'AbstractWriter.php';
1922

2023
/**
2124
* Test class for AbstractWriter
@@ -36,4 +39,24 @@ public function testConstruct()
3639
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Writer\\AbstractWriter', $oStubWriter->setZipAdapter($oStubZip));
3740
$this->assertInstanceOf('PhpOffice\\Common\\Adapter\\Zip\\ZipInterface', $oStubWriter->getZipAdapter());
3841
}
42+
43+
/**
44+
* Test all drawings method
45+
*/
46+
public function testAllDrawings_includesMasterSlides()
47+
{
48+
$presentation = new PhpPresentation();
49+
50+
$activeSlide = $presentation->getActiveSlide();
51+
$activeSlide->createDrawingShape();
52+
53+
$masterSlide = $presentation->getAllMasterSlides()[0];
54+
$masterSlide->createDrawingShape();
55+
56+
$writer = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Tests\\Writer\\AbstractWriter');
57+
$writer->setPhpPresentation($presentation);
58+
59+
$drawings = $writer->allDrawings();
60+
$this->assertEquals(2, count($drawings), 'Number of drawings should equal two: one from normal slide and one from master slide');
61+
}
3962
}

0 commit comments

Comments
 (0)