IOFactoryTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\IOFactory;
  19. use PhpOffice\PhpPresentation\PhpPresentation;
  20. /**
  21. * Test class for IOFactory
  22. *
  23. * @coversDefaultClass PhpOffice\PhpPresentation\IOFactory
  24. */
  25. class IOFactoryTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Test create writer
  29. */
  30. public function testCreateWriter()
  31. {
  32. $class = 'PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007';
  33. $this->assertInstanceOf($class, IOFactory::createWriter(new PhpPresentation()));
  34. }
  35. /**
  36. * Test create reader
  37. */
  38. public function testCreateReader()
  39. {
  40. $class = 'PhpOffice\\PhpPresentation\\Reader\\ReaderInterface';
  41. $this->assertInstanceOf($class, IOFactory::createReader('Serialized'));
  42. }
  43. /**
  44. * Test load class exception
  45. *
  46. * @expectedException \Exception
  47. * @expectedExceptionMessage is not a valid reader
  48. */
  49. public function testLoadClassException()
  50. {
  51. IOFactory::createReader();
  52. }
  53. public function testLoad()
  54. {
  55. $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', IOFactory::load(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.'serialized.phppt'));
  56. }
  57. /**
  58. * Test load class exception
  59. *
  60. * @expectedException \Exception
  61. * @expectedExceptionMessage Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file.
  62. */
  63. public function testLoadException()
  64. {
  65. IOFactory::load(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png');
  66. }
  67. }