Add and improve test coverage
This commit is contained in:
1 parent
2074781852
commit
3f3461b002
12 files changed
+146
-2
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Helper\XLSX;
|
||||
|
||||
/**
|
||||
* Class CellHelperTest
|
||||
*
|
||||
* @package Box\Spout\Reader\Helper\XLSX
|
||||
*/
|
||||
class CellHelperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testFillMissingArrayIndexes()
|
||||
{
|
||||
$arrayToFill = [1 => 1, 3 => 3];
|
||||
$filledArray = CellHelper::fillMissingArrayIndexes($arrayToFill, 'FILL');
|
||||
|
||||
$expectedFilledArray = ['FILL', 1, 'FILL', 3];
|
||||
$this->assertEquals($expectedFilledArray, $filledArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderForTestGetColumnIndexFromCellIndex()
|
||||
{
|
||||
return [
|
||||
['A1', 0],
|
||||
['Z3', 25],
|
||||
['AA5', 26],
|
||||
['AB24', 27],
|
||||
['BC5', 54],
|
||||
['BCZ99', 1455],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProviderForTestGetColumnIndexFromCellIndex
|
||||
*
|
||||
* @param string $cellIndex
|
||||
* @param int $expectedColumnIndex
|
||||
* @return void
|
||||
*/
|
||||
public function testGetColumnIndexFromCellIndex($cellIndex, $expectedColumnIndex)
|
||||
{
|
||||
$this->assertEquals($expectedColumnIndex, CellHelper::getColumnIndexFromCellIndex($cellIndex));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetColumnIndexFromCellIndexShouldThrowIfInvalidCellIndex()
|
||||
{
|
||||
CellHelper::getColumnIndexFromCellIndex('InvalidCellIndex');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader;
|
||||
|
||||
/**
|
||||
* Class ReaderFactoryTest
|
||||
*
|
||||
* @package Box\Spout\Writer
|
||||
*/
|
||||
class ReaderFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Box\Spout\Common\Exception\UnsupportedTypeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateReaderShouldThrowWithUnsupportedType()
|
||||
{
|
||||
ReaderFactory::create('unsupportedType');
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,19 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expectedRows, $allRows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testReadShouldPreserveSpaceIfSpecified()
|
||||
{
|
||||
$allRows = $this->getAllRowsForFile('sheet_with_preserve_space_shared_strings.xlsx');
|
||||
|
||||
$expectedRows = [
|
||||
[' s1--A1', 's1--B1 ', ' s1--C1 '],
|
||||
];
|
||||
$this->assertEquals($expectedRows, $allRows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
@@ -171,7 +184,7 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$allRows = $this->getAllRowsForFile('billion_laughs_test_file.xlsx');
|
||||
|
||||
$expectedMaxMemoryUsage = 10 * 1024 * 1024; // 10MB
|
||||
$expectedMaxMemoryUsage = 20 * 1024 * 1024; // 20MB
|
||||
$this->assertLessThan($expectedMaxMemoryUsage, memory_get_peak_usage(true), 'Entities should not be expanded and therefore consume all the memory.');
|
||||
|
||||
$expectedFirstRow = ['s1--A1', 's1--B1', 's1--C1', 's1--D1', 's1--E1'];
|
||||
|
||||
Reference in new issue
Block a user