'; $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(); $this->assertInstanceOf('PhpOffice\PhpWord\Element\Text', $elements[0]); $this->assertInstanceOf('PhpOffice\PhpWord\Style\Font', $elements[0]->getFontStyle()); /** @var \PhpOffice\PhpWord\Style\Font $fontStyle */ $fontStyle = $elements[0]->getFontStyle(); $this->assertEquals(15, $fontStyle->getPosition()); } }