ADDED : Basic unit tests
This commit is contained in:
parent
4ffa261a6c
commit
79a87a1f8d
@ -41,5 +41,42 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
|
$this->assertRegExp('/z\-index:\-[0-9]*/', $style);
|
||||||
$this->assertRegExp('/position:absolute;/', $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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4,14 +4,14 @@ namespace PHPWord\Tests;
|
|||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit_Framework_TestCase;
|
||||||
use PHPWord;
|
use PHPWord;
|
||||||
use PHPWord_Writer_Word2007;
|
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
|
* @package PHPWord\Tests
|
||||||
* @runTestsInSeparateProcesses
|
* @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
|
* Executed before each method of the class
|
||||||
*/
|
*/
|
||||||
@ -20,63 +20,16 @@ class PHPWord_Writer_Word2007_BaseTest extends \PHPUnit_Framework_TestCase {
|
|||||||
TestHelperDOCX::clear();
|
TestHelperDOCX::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteImage_Position()
|
public function testWriteEndSection_PageNumbering()
|
||||||
{
|
{
|
||||||
$PHPWord = new PHPWord();
|
$PHPWord = new PHPWord();
|
||||||
$section = $PHPWord->createSection();
|
$section = $PHPWord->createSection();
|
||||||
$section->addImage(
|
$section->getSettings()->setPageNumberingStart(2);
|
||||||
PHPWORD_TESTS_DIR_ROOT . '/_files/images/earth.jpg',
|
|
||||||
array(
|
|
||||||
'marginTop' => -1,
|
|
||||||
'marginLeft' => -1,
|
|
||||||
'wrappingStyle' => 'behind'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$doc = TestHelperDOCX::getDocument($PHPWord);
|
$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->assertEquals(2, $element->getAttribute('w:start'));
|
||||||
|
|
||||||
$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'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +23,7 @@
|
|||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
|
|
||||||
Changes in branch for release 0.7.1 :
|
Changes in branch for release 0.7.1 :
|
||||||
|
- QA: (Progi1984) - UnitTests
|
||||||
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
|
- Feature: (gabrielbull) - Word2007 : Support sections page numbering
|
||||||
- Bugfix: (gabrielbull) - Fixed bug with cell styling
|
- Bugfix: (gabrielbull) - Fixed bug with cell styling
|
||||||
- Bugfix: (gabrielbull) - Fixed bug list items inside of cells
|
- Bugfix: (gabrielbull) - Fixed bug list items inside of cells
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user