ADDED : Basic unit tests

This commit is contained in:
Progi1984 2014-02-24 19:38:44 +01:00
parent 4ffa261a6c
commit 79a87a1f8d
3 changed files with 45 additions and 54 deletions

View File

@ -41,5 +41,42 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
$this->assertRegExp('/position:absolute;/', $style);
}
public function testWriteParagraphStyle_Align()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$section->addText('This is my text', null, array('align' => 'right'));
$doc = TestHelperDOCX::getDocument($PHPWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
$this->assertEquals('right', $element->getAttribute('w:val'));
}
public function testWriteCellStyle_CellGridSpan()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell(200);
$cell->getStyle()->setGridSpan(5);
$table->addRow();
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$doc = TestHelperDOCX::getDocument($PHPWord);
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
$this->assertEquals(5, $element->getAttribute('w:val'));
}
}

View File

@ -4,14 +4,14 @@ namespace PHPWord\Tests;
use PHPUnit_Framework_TestCase;
use PHPWord;
use PHPWord_Writer_Word2007;
use PHPWord_Writer_Word2007_Base;
use PHPWord_Writer_Word2007_Document;
/**
* Class PHPWord_Writer_Word2007_BaseTest
* Class PHPWord_Writer_Word2007_DocumentTest
* @package PHPWord\Tests
* @runTestsInSeparateProcesses
*/
class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
class PHPWord_Writer_Word2007_DocumentTest extends \PHPUnit_Framework_TestCase {
/**
* Executed before each method of the class
*/
@ -20,63 +20,16 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
TestHelperDOCX::clear();
}
public function testWriteImage_Position()
public function testWriteEndSection_PageNumbering()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$section->addImage(
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
array(
'marginTop' => -1,
'marginLeft' => -1,
'wrappingStyle' => 'behind'
)
);
$section->getSettings()->setPageNumberingStart(2);
$doc = TestHelperDOCX::getDocument($PHPWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:r/w:pict/v:shape');
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
$style = $element->getAttribute('style');
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
$this->assertRegExp('/position:absolute;/', $style);
$this->assertEquals(2, $element->getAttribute('w:start'));
}
public function testWriteParagraphStyle_Align()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$section->addText('This is my text', null, array('align' => 'right'));
$doc = TestHelperDOCX::getDocument($PHPWord);
$element = $doc->getElement('/w:document/w:body/w:p/w:pPr/w:jc');
$this->assertEquals('right', $element->getAttribute('w:val'));
}
public function testWriteCellStyle_CellGridSpan()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell(200);
$cell->getStyle()->setGridSpan(5);
$table->addRow();
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$table->addCell(40);
$doc = TestHelperDOCX::getDocument($PHPWord);
$element = $doc->getElement('/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:gridSpan');
$this->assertEquals(5, $element->getAttribute('w:val'));
}
}

View File

@ -23,6 +23,7 @@
**************************************************************************************
Changes in branch for release 0.7.1 :
- QA: (Progi1984) - UnitTests
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
- Bugfix: (gabrielbull) - Fixed bug with cell styling
- Bugfix: (gabrielbull) - Fixed bug list items inside of cells