/** * Write footer */ public function testWriteFooter() { $imageSrc = __DIR__ . '/../../../_files/images/PhpWord.png'; $container = new \PhpOffice\PhpWord\Element\Footer(1); $container->addText(htmlspecialchars('', ENT_COMPAT, 'UTF-8')); $container->addPreserveText(htmlspecialchars('', ENT_COMPAT, 'UTF-8')); $container->addTextBreak(); $container->addTextRun(); $container->addTable()->addRow()->addCell()->addText(htmlspecialchars('', ENT_COMPAT, 'UTF-8')); $container->addImage($imageSrc); $writer = new Word2007(); $writer->setUseDiskCaching(true); $object = new Footer(); $object->setParentWriter($writer); $object->setElement($container); $xml = simplexml_load_string($object->write()); $this->assertInstanceOf('SimpleXMLElement', $xml); }
/** * Write header */ public function testWriteHeader() { $imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png"; $container = new \PhpOffice\PhpWord\Element\Header(1); $container->addText('Test'); $container->addPreserveText(''); $container->addTextBreak(); $container->addTextRun(); $container->addTable()->addRow()->addCell()->addText(''); $container->addImage($imageSrc); $container->addWatermark($imageSrc); $writer = new Word2007(); $writer->setUseDiskCaching(true); $object = new Header(); $object->setParentWriter($writer); $object->setElement($container); $xml = simplexml_load_string($object->write()); $this->assertInstanceOf('SimpleXMLElement', $xml); }
/** * Use disk caching exception * * @expectedException \PhpOffice\PhpWord\Exception\Exception */ public function testSetUseDiskCachingException() { $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_BASE_DIR, 'foo')); $object = new Word2007(); $object->setUseDiskCaching(true, $dir); }