Add testcase
This commit is contained in:
parent
58e0200fbd
commit
ae34ae9518
|
|
@ -36,7 +36,7 @@
|
|||
],
|
||||
"scripts": {
|
||||
"test": [
|
||||
"phpunit --color=always"
|
||||
"phpunit --color=always --filter testReadAlternateContent"
|
||||
],
|
||||
"test-no-coverage": [
|
||||
"phpunit --color=always --no-coverage"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,49 @@ use PhpOffice\PhpWord\Element\TrackChange;
|
|||
*/
|
||||
class ElementTest extends AbstractTestReader
|
||||
{
|
||||
/**
|
||||
* Test reading of alternate content value
|
||||
*/
|
||||
public function testReadAlternateContent()
|
||||
{
|
||||
$documentXml = '<w:p>
|
||||
<w:r>
|
||||
<mc:AlternateContent>
|
||||
<mc:Choice Requires="wps"></mc:Choice>
|
||||
<mc:Fallback>
|
||||
<w:pict>
|
||||
<v:rect>
|
||||
<v:textbox>
|
||||
<w:txbxContent>
|
||||
<w:p>
|
||||
<w:pPr>
|
||||
<w:jc w:val="center"/>
|
||||
</w:pPr>
|
||||
<w:r>
|
||||
<w:t>Test node value</w:t>
|
||||
</w:r>
|
||||
</w:p>
|
||||
</w:txbxContent>
|
||||
</v:textbox>
|
||||
</v:rect>
|
||||
</w:pict>
|
||||
</mc:Fallback>
|
||||
</mc:AlternateContent>
|
||||
</w:r>
|
||||
</w:p>';
|
||||
|
||||
$phpWord = $this->getDocumentFromString(array('document' => $documentXml));
|
||||
|
||||
$elements = $phpWord->getSection(0)->getElements();
|
||||
|
||||
$this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $elements[0]);
|
||||
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $elements[0]->getElement(0));
|
||||
|
||||
$text = $elements[0];
|
||||
|
||||
$this->assertEquals('Test node value', trim($text->getElement(0)->getText()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reading of textbreak
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ abstract class AbstractTestReader extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
private $parts = array(
|
||||
'styles' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Styles', 'xml' => '<w:styles xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:docDefaults><w:rPrDefault><w:rPr><w:sz w:val="24"/></w:rPr></w:rPrDefault></w:docDefaults>{toReplace}</w:styles>'),
|
||||
'document' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Document', 'xml' => '<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body>{toReplace}</w:body></w:document>'),
|
||||
'document' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Document', 'xml' => '<w:document xmlns:v="urn:schemas-microsoft-com:vml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body>{toReplace}</w:body></w:document>'),
|
||||
'footnotes' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Footnotes', 'xml' => '<w:footnotes xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">{toReplace}</w:footnotes>'),
|
||||
'endnotes' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Endnotes', 'xml' => '<w:endnotes xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">{toReplace}</w:endnotes>'),
|
||||
'settings' => array('class' => 'PhpOffice\PhpWord\Reader\Word2007\Settings', 'xml' => '<w:comments xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">{toReplace}</w:comments>'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue