diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 0899990b..316e56fc 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -33,9 +33,9 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart /** * Write content file to XML format * - * @param PHPWord $pPHPWord - * @return string XML Output - * @throws Exception + * @param PHPWord $pPHPWord + * @return string XML Output + * @throws Exception */ public function writeContent(PHPWord $pPHPWord = null) { diff --git a/Classes/PHPWord/Writer/ODText/Manifest.php b/Classes/PHPWord/Writer/ODText/Manifest.php index 89e802dc..0d627ec9 100755 --- a/Classes/PHPWord/Writer/ODText/Manifest.php +++ b/Classes/PHPWord/Writer/ODText/Manifest.php @@ -113,9 +113,10 @@ class PHPWord_Writer_ODText_Manifest extends PHPWord_Writer_ODText_WriterPart /** * Get image mime type * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + * @codeCoverageIgnore Image is not yet handled by ODText */ private function _getImageMimeType($pFile = '') { diff --git a/Classes/PHPWord/Writer/Word2007.php b/Classes/PHPWord/Writer/Word2007.php index e62341bf..0f9aac14 100755 --- a/Classes/PHPWord/Writer/Word2007.php +++ b/Classes/PHPWord/Writer/Word2007.php @@ -289,4 +289,14 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter $this->checkContentTypes($element['source']); } } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() + { + return $this->_diskCachingDirectory; + } } diff --git a/Tests/PHPWord/Writer/ODText/WriterPartTest.php b/Tests/PHPWord/Writer/ODText/WriterPartTest.php new file mode 100644 index 00000000..f7b70ba2 --- /dev/null +++ b/Tests/PHPWord/Writer/ODText/WriterPartTest.php @@ -0,0 +1,45 @@ +getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->setParentWriter(new PHPWord_Writer_ODText()); + $this->assertEquals( + new PHPWord_Writer_ODText(), + $object->getParentWriter() + ); + } + + /** + * covers ::getParentWriter + * @expectedException Exception + * @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned. + */ + public function testSetGetParentWriterNull() + { + $object = $this->getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->getParentWriter(); + } +} diff --git a/Tests/PHPWord/Writer/ODTextTest.php b/Tests/PHPWord/Writer/ODTextTest.php index ef92d249..7cc49fba 100644 --- a/Tests/PHPWord/Writer/ODTextTest.php +++ b/Tests/PHPWord/Writer/ODTextTest.php @@ -92,19 +92,6 @@ class ODTextTest extends \PHPUnit_Framework_TestCase unlink($file); } - /** - * @covers ::save - * @todo Haven't got any method to test this - */ - public function testSavePhpOutput() - { - $phpWord = new PHPWord(); - $section = $phpWord->createSection(); - $section->addText('Test'); - $writer = new PHPWord_Writer_ODText($phpWord); - $writer->save('php://output'); - } - /** * @covers ::save * @expectedException Exception diff --git a/Tests/PHPWord/Writer/RTFTest.php b/Tests/PHPWord/Writer/RTFTest.php index d071def7..8735c7d7 100644 --- a/Tests/PHPWord/Writer/RTFTest.php +++ b/Tests/PHPWord/Writer/RTFTest.php @@ -35,19 +35,6 @@ class RTFTest extends \PHPUnit_Framework_TestCase $object->getPHPWord(); } - /** - * @covers ::save - * @todo Haven't got any method to test this - */ - public function testSavePhpOutput() - { - $phpWord = new PHPWord(); - $section = $phpWord->createSection(); - $section->addText('Test'); - $writer = new PHPWord_Writer_RTF($phpWord); - $writer->save('php://output'); - } - /** * @covers ::save * @expectedException Exception @@ -78,13 +65,15 @@ class RTFTest extends \PHPUnit_Framework_TestCase array(\PHPWORD_TESTS_DIR_ROOT, '_files', 'temp.rtf') ); + $fontStyle = array('name' => 'Verdana', 'size' => 11, 'bold' => true, 'italic' => true, 'color' => 'F29101', 'fgColor' => '123456'); + $paragraphStyle = array('align' => 'center', 'spaceAfter' => 120); $phpWord = new PHPWord(); - $phpWord->addFontStyle('Font', array('size' => 11)); - $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); + $phpWord->addFontStyle('Font', $fontStyle); + $phpWord->addParagraphStyle('Paragraph', $paragraphStyle); $section = $phpWord->createSection(); $section->addText('Test 1', 'Font'); + $section->addText('Test 2', array('name' => 'Tahoma'), 'Paragraph'); $section->addTextBreak(); - $section->addText('Test 2', null, 'Paragraph'); $section->addLink('http://test.com'); $section->addTitle('Test', 1); $section->addPageBreak(); diff --git a/Tests/PHPWord/Writer/Word2007/FooterTest.php b/Tests/PHPWord/Writer/Word2007/FooterTest.php new file mode 100644 index 00000000..1facc622 --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/FooterTest.php @@ -0,0 +1,44 @@ +addText(''); + $container->addPreserveText(''); + $container->addTextBreak(); + $container->createTextRun(); + $container->addTable()->addRow()->addCell()->addText(''); + $container->addImage($imageSrc); + + $writer = new PHPWord_Writer_Word2007(); + $object = new PHPWord_Writer_Word2007_Footer(); + $object->setParentWriter($writer); + $object->writeFooter($container); + $writer->setUseDiskCaching(true); + $xml = simplexml_load_string($object->writeFooter($container)); + + $this->assertInstanceOf('SimpleXMLElement', $xml); + } +} diff --git a/Tests/PHPWord/Writer/Word2007/HeaderTest.php b/Tests/PHPWord/Writer/Word2007/HeaderTest.php new file mode 100644 index 00000000..f4972b7c --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/HeaderTest.php @@ -0,0 +1,46 @@ +addText('Test'); + $container->addPreserveText(''); + $container->addTextBreak(); + $container->createTextRun(); + $container->addTable()->addRow()->addCell()->addText(''); + $container->addImage($imageSrc); + $container->addWatermark($imageSrc); + + $writer = new PHPWord_Writer_Word2007(); + $object = new PHPWord_Writer_Word2007_Header(); + $object->setParentWriter($writer); + $object->writeHeader($container); + $writer->setUseDiskCaching(true); + $xml = simplexml_load_string($object->writeHeader($container)); + + $this->assertInstanceOf('SimpleXMLElement', $xml); + } +} diff --git a/Tests/PHPWord/Writer/Word2007/WriterPartTest.php b/Tests/PHPWord/Writer/Word2007/WriterPartTest.php new file mode 100644 index 00000000..3d983178 --- /dev/null +++ b/Tests/PHPWord/Writer/Word2007/WriterPartTest.php @@ -0,0 +1,45 @@ +getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->setParentWriter(new PHPWord_Writer_Word2007()); + $this->assertEquals( + new PHPWord_Writer_Word2007(), + $object->getParentWriter() + ); + } + + /** + * covers ::getParentWriter + * @expectedException Exception + * @expectedExceptionMessage No parent PHPWord_Writer_IWriter assigned. + */ + public function testSetGetParentWriterNull() + { + $object = $this->getMockForAbstractClass( + 'PHPWord_Writer_Word2007_WriterPart' + ); + $object->getParentWriter(); + } +} diff --git a/Tests/PHPWord/Writer/Word2007Test.php b/Tests/PHPWord/Writer/Word2007Test.php index 95abee83..ca1d7d82 100644 --- a/Tests/PHPWord/Writer/Word2007Test.php +++ b/Tests/PHPWord/Writer/Word2007Test.php @@ -67,6 +67,26 @@ class Word2007Test extends \PHPUnit_Framework_TestCase unlink($file); } + /** + * @covers ::save + * @expectedException Exception + * @expectedExceptionMessage PHPWord object unassigned. + */ + public function testSaveException() + { + $writer = new PHPWord_Writer_Word2007(); + $writer->save(); + } + + /** + * @covers ::getWriterPart + */ + public function testGetWriterPartNull() + { + $object = new PHPWord_Writer_Word2007(); + $this->assertNull($object->getWriterPart('foo')); + } + /** * @covers ::checkContentTypes */ @@ -100,13 +120,14 @@ class Word2007Test extends \PHPUnit_Framework_TestCase /** * @covers ::setUseDiskCaching * @covers ::getUseDiskCaching + * @covers ::getDiskCachingDirectory */ public function testSetGetUseDiskCaching() { $object = new PHPWord_Writer_Word2007(); $object->setUseDiskCaching(true, PHPWORD_TESTS_DIR_ROOT); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertEquals(PHPWORD_TESTS_DIR_ROOT, $object->getDiskCachingDirectory()); } /**