'; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Table', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Table', $elements[0]->getStyle()); $this->assertEquals(Table::LAYOUT_FIXED, $elements[0]->getStyle()->getLayout()); } /** * Test reading of cell spacing */ public function testReadCellSpacing() { $documentXml = ' '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Table', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Table', $elements[0]->getStyle()); /** @var \PhpOffice\PhpWord\Style\Table $tableStyle */ $tableStyle = $elements[0]->getStyle(); $this->assertEquals(TblWidth::AUTO, $tableStyle->getUnit()); $this->assertEquals(10.5, $tableStyle->getCellSpacing()); } /** * Test reading of table position */ public function testReadTablePosition() { $documentXml = ' '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Table', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Table', $elements[0]->getStyle()); $this->assertNotNull($elements[0]->getStyle()->getPosition()); $this->assertInstanceOf('PhpOffice\PhpWord\Style\TablePosition', $elements[0]->getStyle()->getPosition()); /** @var \PhpOffice\PhpWord\Style\TablePosition $tableStyle */ $tableStyle = $elements[0]->getStyle()->getPosition(); $this->assertEquals(10, $tableStyle->getLeftFromText()); $this->assertEquals(20, $tableStyle->getRightFromText()); $this->assertEquals(30, $tableStyle->getTopFromText()); $this->assertEquals(40, $tableStyle->getBottomFromText()); $this->assertEquals(TablePosition::VANCHOR_PAGE, $tableStyle->getVertAnchor()); $this->assertEquals(TablePosition::HANCHOR_MARGIN, $tableStyle->getHorzAnchor()); $this->assertEquals(TablePosition::XALIGN_CENTER, $tableStyle->getTblpXSpec()); $this->assertEquals(50, $tableStyle->getTblpX()); $this->assertEquals(TablePosition::YALIGN_TOP, $tableStyle->getTblpYSpec()); $this->assertEquals(60, $tableStyle->getTblpY()); } /** * Test reading of position */ public function testReadPosition() { $documentXml = ' This text is lowered '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); /** @var \PhpOffice\PhpWord\Element\TextRun $elements */ $textRun = $elements[0]; $this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $textRun); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $textRun->getElement(0)); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Font', $textRun->getElement(0)->getFontStyle()); /** @var \PhpOffice\PhpWord\Style\Font $fontStyle */ $fontStyle = $textRun->getElement(0)->getFontStyle(); $this->assertEquals(15, $fontStyle->getPosition()); } public function testReadIndent() { $documentXml = ' '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Table', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Table', $elements[0]->getStyle()); /** @var \PhpOffice\PhpWord\Style\Table $tableStyle */ $tableStyle = $elements[0]->getStyle(); $this->assertSame(TblWidth::TWIP, $tableStyle->getIndent()->getType()); $this->assertSame(2160, $tableStyle->getIndent()->getValue()); } public function testReadTableRTL() { $documentXml = ' '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Table', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Table', $elements[0]->getStyle()); /** @var \PhpOffice\PhpWord\Style\Table $tableStyle */ $tableStyle = $elements[0]->getStyle(); $this->assertTrue($tableStyle->isBidiVisual()); } public function testReadHidden() { $documentXml = ' This text is hidden '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $elements = $phpWord->getSection(0)->getElements(); /** @var \PhpOffice\PhpWord\Element\TextRun $elements */ $textRun = $elements[0]; $this->assertInstanceOf('PhpOffice\PhpWord\Element\TextRun', $textRun); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $textRun->getElement(0)); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Font', $textRun->getElement(0)->getFontStyle()); /** @var \PhpOffice\PhpWord\Style\Font $fontStyle */ $fontStyle = $textRun->getElement(0)->getFontStyle(); $this->assertTrue($fontStyle->isHidden()); } public function testReadHeading() { Style::resetStyles(); $documentXml = ' '; $name = 'Heading_1'; $this->getDocumentFromString(array('styles' => $documentXml)); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($name)); } public function testPageVerticalAlign() { $documentXml = ' '; $phpWord = $this->getDocumentFromString(array('document' => $documentXml)); $sectionStyle = $phpWord->getSection(0)->getStyle(); $this->assertEquals(VerticalJc::CENTER, $sectionStyle->getVAlign()); } }