From a41c37c1e116581c9fdddf0ed72f3921f2a15095 Mon Sep 17 00:00:00 2001 From: Manunchik <56105206+Manunchik@users.noreply.github.com> Date: Tue, 22 Oct 2019 14:10:26 +0500 Subject: [PATCH] Add PhpOffice\PhpWord\Cell\IOFactory::createWriter unit test --- tests/PhpWord/IOFactoryTest.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/PhpWord/IOFactoryTest.php b/tests/PhpWord/IOFactoryTest.php index 4a59e7022a..93a4b24657 100644 --- a/tests/PhpWord/IOFactoryTest.php +++ b/tests/PhpWord/IOFactoryTest.php @@ -24,6 +24,39 @@ */ class IOFactoryTest extends \PHPUnit\Framework\TestCase { + public function setUp() + { + $rendererName = Settings::PDF_RENDERER_DOMPDF; + $rendererLibraryPath = realpath(PHPWORD_TESTS_BASE_DIR . '/../vendor/dompdf/dompdf'); + Settings::setPdfRenderer($rendererName, $rendererLibraryPath); + } + + /** + * Create all possible writers + * + * @dataProvider providerCreateWriter + * + * @param string $name + * @param string $expected + */ + public function testCreateWriter($name, $expected) + { + $phpWord = new PhpWord(); + $actual = IOFactory::createWriter($phpWord, $name); + self::assertInstanceOf($expected, $actual); + } + + public function providerCreateWriter() + { + return array( + array('ODText', Writer\ODText::class), + array('RTF', Writer\RTF::class), + array('Word2007', Writer\Word2007::class), + array('HTML', Writer\HTML::class), + array('PDF', Writer\PDF::class), + ); + } + /** * Create existing writer */