AbstractWriterTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Writer;
  18. use PhpOffice\PhpPresentation\PhpPresentation;
  19. require 'AbstractWriter.php';
  20. /**
  21. * Test class for AbstractWriter
  22. *
  23. * @coversDefaultClass AbstractWriter
  24. */
  25. class AbstractWriterTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create new instance
  29. */
  30. public function testConstruct()
  31. {
  32. $oStubWriter = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Writer\AbstractWriter');
  33. $oStubZip = $this->getMockForAbstractClass('PhpOffice\Common\Adapter\Zip\ZipInterface');
  34. $this->assertNull($oStubWriter->getZipAdapter());
  35. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Writer\\AbstractWriter', $oStubWriter->setZipAdapter($oStubZip));
  36. $this->assertInstanceOf('PhpOffice\\Common\\Adapter\\Zip\\ZipInterface', $oStubWriter->getZipAdapter());
  37. }
  38. /**
  39. * Test all drawings method
  40. */
  41. public function testAllDrawingsIncludesMasterSlides()
  42. {
  43. $presentation = new PhpPresentation();
  44. $activeSlide = $presentation->getActiveSlide();
  45. $activeSlide->createDrawingShape();
  46. $masterSlides = $presentation->getAllMasterSlides();
  47. $masterSlide = $masterSlides[0];
  48. $masterSlide->createDrawingShape();
  49. $writer = $this->getMockForAbstractClass('PhpOffice\\PhpPresentation\\Tests\\Writer\\AbstractWriter');
  50. $writer->setPhpPresentation($presentation);
  51. $drawings = $writer->allDrawings();
  52. $this->assertEquals(2, count($drawings), 'Number of drawings should equal two: one from normal slide and one from master slide');
  53. }
  54. }