test string
';
$phpWord = $this->getDocumentFromString(array('document' => $documentXml));
$elements = $phpWord->getSection(0)->getElements();
$this->assertInstanceOf('PhpOffice\PhpWord\Element\TextBreak', $elements[0]);
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $elements[1]);
$this->assertEquals('test string', $elements[1]->getText());
}
/**
* Test reading of textbreak
*/
public function testReadListItemRunWithFormatting()
{
$documentXml = '
Two
with
bold
';
$phpWord = $this->getDocumentFromString(array('document' => $documentXml));
$sections = $phpWord->getSection(0);
$this->assertNull($sections->getElement(999));
$this->assertInstanceOf('PhpOffice\PhpWord\Element\ListItemRun', $sections->getElement(0));
$this->assertEquals(0, $sections->getElement(0)->getDepth());
$listElements = $sections->getElement(0)->getElements();
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $listElements[0]);
$this->assertEquals('Two', $listElements[0]->getText());
$this->assertEquals(' with ', $listElements[1]->getText());
$this->assertEquals('bold', $listElements[2]->getText());
$this->assertTrue($listElements[2]->getFontStyle()->getBold());
}
/**
* Test reading Title style
*/
public function testReadTitleStyle()
{
$documentXml = '
This is a non formatted title
This is a
bold
title
';
$stylesXml = '
';
$phpWord = $this->getDocumentFromString(array('document' => $documentXml, 'styles' => $stylesXml));
$elements = $phpWord->getSection(0)->getElements();
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Title', $elements[0]);
/** @var \PhpOffice\PhpWord\Element\Title $title */
$title = $elements[0];
$this->assertEquals('Title', $title->getStyle());
$this->assertEquals('This is a non formatted title', $title->getText());
$this->assertInstanceOf('PhpOffice\PhpWord\Element\Title', $elements[1]);
/** @var \PhpOffice\PhpWord\Element\Title $formattedTitle */
$formattedTitle = $elements[1];
$this->assertEquals('Title', $formattedTitle->getStyle());
$this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $formattedTitle->getText());
}
}