PHPWord/test/PhpWord/Section/TableTest.php

61 lines
1.7 KiB
PHP
Raw Normal View History

2014-03-09 19:09:22 +01:00
<?php
namespace PhpWord\Tests\Section;
2014-03-09 19:09:22 +01:00
use PhpOffice\PhpWord\Section\Table;
2014-03-09 19:09:22 +01:00
2014-03-09 15:04:23 -04:00
class TableTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oTable = new Table('section', 1);
2014-03-09 15:04:23 -04:00
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table', $oTable);
2014-03-09 15:04:23 -04:00
$this->assertEquals($oTable->getStyle(), null);
$this->assertEquals($oTable->getWidth(), null);
$this->assertEquals($oTable->getRows(), array());
$this->assertCount(0, $oTable->getRows());
}
public function testStyleText()
{
$oTable = new Table('section', 1, 'tableStyle');
2014-03-09 15:04:23 -04:00
$this->assertEquals($oTable->getStyle(), 'tableStyle');
}
public function testStyleArray()
{
$oTable = new Table(
'section',
1,
array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80)
);
2014-03-09 15:04:23 -04:00
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Table', $oTable->getStyle());
2014-03-09 15:04:23 -04:00
}
public function testWidth()
{
$oTable = new Table('section', 1);
2014-03-09 15:04:23 -04:00
$iVal = rand(1, 1000);
$oTable->setWidth($iVal);
$this->assertEquals($oTable->getWidth(), $iVal);
}
public function testRow()
{
$oTable = new Table('section', 1);
2014-03-09 15:04:23 -04:00
$element = $oTable->addRow();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Row', $element);
2014-03-09 15:04:23 -04:00
$this->assertCount(1, $oTable->getRows());
}
public function testCell()
{
$oTable = new Table('section', 1);
2014-03-09 15:04:23 -04:00
$oTable->addRow();
$element = $oTable->addCell();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Table\\Cell', $element);
2014-03-09 15:04:23 -04:00
}
}