No Description

IOFactoryTest.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord 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/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Tests;
  18. use PhpOffice\PhpWord\IOFactory;
  19. use PhpOffice\PhpWord\PhpWord;
  20. /**
  21. * Test class for PhpOffice\PhpWord\IOFactory
  22. *
  23. * @runTestsInSeparateProcesses
  24. */
  25. class IOFactoryTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Create existing writer
  29. */
  30. public function testExistingWriterCanBeCreated()
  31. {
  32. $this->assertInstanceOf(
  33. 'PhpOffice\\PhpWord\\Writer\\Word2007',
  34. IOFactory::createWriter(new PhpWord(), 'Word2007')
  35. );
  36. }
  37. /**
  38. * Create non-existing writer
  39. *
  40. * @expectedException \PhpOffice\PhpWord\Exception\Exception
  41. */
  42. public function testNonexistentWriterCanNotBeCreated()
  43. {
  44. IOFactory::createWriter(new PhpWord(), 'Word2006');
  45. }
  46. /**
  47. * Create existing reader
  48. */
  49. public function testExistingReaderCanBeCreated()
  50. {
  51. $this->assertInstanceOf(
  52. 'PhpOffice\\PhpWord\\Reader\\Word2007',
  53. IOFactory::createReader('Word2007')
  54. );
  55. }
  56. /**
  57. * Create non-existing reader
  58. *
  59. * @expectedException \PhpOffice\PhpWord\Exception\Exception
  60. */
  61. public function testNonexistentReaderCanNotBeCreated()
  62. {
  63. IOFactory::createReader('Word2006');
  64. }
  65. /**
  66. * Load document
  67. */
  68. public function testLoad()
  69. {
  70. $file = __DIR__ . "/_files/templates/blank.docx";
  71. $this->assertInstanceOf(
  72. 'PhpOffice\\PhpWord\\PhpWord',
  73. IOFactory::load($file)
  74. );
  75. }
  76. }