Add some unit tests for Shared & Element (100%!) - @Progi1984
This commit is contained in:
parent
59e623bb75
commit
b40218da45
|
|
@ -35,6 +35,7 @@ This release marked heavy refactorings on internal code structure with the creat
|
|||
### Bugfixes
|
||||
|
||||
- Footnote: Footnote content doesn't show footnote reference number - @ivanlanin GH-170
|
||||
- Documentation : Error in a fonction - @theBeerNut GH-195
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ This release marked heavy refactorings on internal code structure with the creat
|
|||
- Style: New `Style\AbstractStyle` abstract class - @ivanlanin GH-187
|
||||
- Writer: New 'ODText\Base` class - @ivanlanin GH-187
|
||||
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
|
||||
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
|
||||
|
||||
## 0.9.1 - 27 Mar 2014
|
||||
|
||||
|
|
|
|||
|
|
@ -218,8 +218,7 @@ class ZipArchive
|
|||
public function getNameIndex($index)
|
||||
{
|
||||
$list = $this->zip->listContent();
|
||||
$listCount = count($list);
|
||||
if ($index <= $listCount) {
|
||||
if (isset($list[$index])) {
|
||||
return $list[$index]['filename'];
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPWord
|
||||
*
|
||||
* @link https://github.com/PHPOffice/PHPWord
|
||||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Tests\Element;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Element\Cell
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class AbstractElementTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testElementIndex(){
|
||||
$stub = $this->getMockForAbstractClass('\PhpOffice\PhpWord\Element\AbstractElement');
|
||||
$ival = rand(0, 100);
|
||||
$stub->setElementIndex($ival);
|
||||
$this->assertEquals($stub->getElementIndex(), $ival);
|
||||
}
|
||||
public function testElementId(){
|
||||
$stub = $this->getMockForAbstractClass('\PhpOffice\PhpWord\Element\AbstractElement');
|
||||
$stub->setElementId();
|
||||
$this->assertEquals(strlen($stub->getElementId()), 6);
|
||||
}
|
||||
}
|
||||
|
|
@ -94,6 +94,11 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle());
|
||||
}
|
||||
|
||||
public function testStyleWrappingStyle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get relation Id
|
||||
*/
|
||||
|
|
@ -202,4 +207,14 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$object = new Image('test.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test PCX Image and Memory
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
public function testPcxImage()
|
||||
{
|
||||
$object = new Image('http://samples.libav.org/image-samples/RACECAR.BMP');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,18 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
|||
$element = $oTable->addCell();
|
||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add cell
|
||||
*/
|
||||
public function testCountColumns()
|
||||
{
|
||||
$oTable = new Table('section', 1);
|
||||
$oTable->addRow();
|
||||
$element = $oTable->addCell();
|
||||
$this->assertEquals($oTable->countColumns(), 1);
|
||||
$element = $oTable->addCell();
|
||||
$element = $oTable->addCell();
|
||||
$this->assertEquals($oTable->countColumns(), 3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,37 @@ class ZipArchiveTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertTrue($object->locateName('xls/new.xls'));
|
||||
$this->assertEquals('Test', $object->getFromName('content/string.txt'));
|
||||
$this->assertEquals('Test', $object->getFromName('/content/string.txt'));
|
||||
|
||||
unlink($zipFile);
|
||||
}
|
||||
|
||||
public function testLocate()
|
||||
{
|
||||
$existingFile = __DIR__ . "/../_files/documents/sheet.xls";
|
||||
$zipFile = __DIR__ . "/../_files/documents/ziptest.zip";
|
||||
$object = new ZipArchive();
|
||||
$object->open($zipFile);
|
||||
$object->addFile($existingFile, 'xls/new.xls');
|
||||
$object->addFromString('content/string.txt', 'Test');
|
||||
|
||||
$this->assertEquals(1, $object->locateName('content/string.txt'));
|
||||
$this->assertFalse($object->locateName('blablabla'));
|
||||
|
||||
unlink($zipFile);
|
||||
}
|
||||
|
||||
public function testNameIndex()
|
||||
{
|
||||
$existingFile = __DIR__ . "/../_files/documents/sheet.xls";
|
||||
$zipFile = __DIR__ . "/../_files/documents/ziptest.zip";
|
||||
$object = new ZipArchive();
|
||||
$object->open($zipFile);
|
||||
$object->addFile($existingFile, 'xls/new.xls');
|
||||
$object->addFromString('content/string.txt', 'Test');
|
||||
|
||||
$this->assertFalse($object->getNameIndex(-1));
|
||||
$this->assertEquals('content/string.txt', $object->getNameIndex(1));
|
||||
|
||||
unlink($zipFile);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue