Merge Reader and Writer entities
Merged Cell/Row/Style entities
This commit is contained in:
1 parent
4d1d1c1e87
commit
f5168114d0
66 files changed
+183
-576
No files matched your search
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Common\Entity;
|
||||
|
||||
class CellTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testValidInstance()
|
||||
{
|
||||
$this->assertInstanceOf(Cell::class, new Cell('cell'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeNumeric()
|
||||
{
|
||||
$this->assertTrue((new Cell(0))->isNumeric());
|
||||
$this->assertTrue((new Cell(1))->isNumeric());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeString()
|
||||
{
|
||||
$this->assertTrue((new Cell('String!'))->isString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeEmptyString()
|
||||
{
|
||||
$this->assertTrue((new Cell(''))->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeEmptyNull()
|
||||
{
|
||||
$this->assertTrue((new Cell(null))->isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeBool()
|
||||
{
|
||||
$this->assertTrue((new Cell(true))->isBoolean());
|
||||
$this->assertTrue((new Cell(false))->isBoolean());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCellTypeError()
|
||||
{
|
||||
$this->assertTrue((new Cell([]))->isError());
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Spout\Reader\Common\Entity;
|
||||
|
||||
class RowTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @return \PHPUnit_Framework_MockObject_MockObject|Cell
|
||||
*/
|
||||
private function getCellMock()
|
||||
{
|
||||
return $this->createMock(Cell::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testValidInstance()
|
||||
{
|
||||
$this->assertInstanceOf(Row::class, new Row([], null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetCells()
|
||||
{
|
||||
$row = new Row([], null);
|
||||
$row->setCells([$this->getCellMock(), $this->getCellMock()]);
|
||||
|
||||
$this->assertEquals(2, $row->getNumCells());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSetCellsResets()
|
||||
{
|
||||
$row = new Row([], null);
|
||||
$row->setCells([$this->getCellMock(), $this->getCellMock()]);
|
||||
|
||||
$this->assertEquals(2, $row->getNumCells());
|
||||
|
||||
$row->setCells([$this->getCellMock()]);
|
||||
|
||||
$this->assertEquals(1, $row->getNumCells());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGetCells()
|
||||
{
|
||||
$row = new Row([], null);
|
||||
|
||||
$this->assertEquals(0, $row->getNumCells());
|
||||
|
||||
$row->setCells([$this->getCellMock(), $this->getCellMock()]);
|
||||
|
||||
$this->assertEquals(2, $row->getNumCells());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddCell()
|
||||
{
|
||||
$row = new Row([], null);
|
||||
$row->setCells([$this->getCellMock(), $this->getCellMock()]);
|
||||
|
||||
$this->assertEquals(2, $row->getNumCells());
|
||||
|
||||
$row->addCell($this->getCellMock());
|
||||
|
||||
$this->assertEquals(3, $row->getNumCells());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testFluentInterface()
|
||||
{
|
||||
$row = new Row([], null);
|
||||
$row
|
||||
->addCell($this->getCellMock())
|
||||
->setCells([]);
|
||||
|
||||
$this->assertTrue(is_object($row));
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Box\Spout\Reader\Common\Manager;
|
||||
|
||||
use Box\Spout\Reader\Common\Entity\Cell;
|
||||
use Box\Spout\Reader\Common\Entity\Row;
|
||||
use Box\Spout\Common\Entity\Cell;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
use Box\Spout\Reader\XLSX\Creator\HelperFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Reader\XLSX\Creator\ManagerFactory;
|
||||
@@ -37,7 +37,7 @@ class RowManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$rowManager = $this->createRowManager();
|
||||
|
||||
$rowToFill = new Row([]);
|
||||
$rowToFill = new Row([], null);
|
||||
foreach ($rowCells as $cellIndex => $cell) {
|
||||
$rowToFill->setCellAtIndex($cell, $cellIndex);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class RowManagerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testIsEmptyRow(array $cells, $expectedIsEmpty)
|
||||
{
|
||||
$rowManager = $this->createRowManager();
|
||||
$row = new Row($cells);
|
||||
$row = new Row($cells, null);
|
||||
|
||||
$this->assertEquals($expectedIsEmpty, $rowManager->isEmpty($row));
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class CellValueFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
if ($expectedDateAsString === null) {
|
||||
$this->fail('An exception should have been thrown');
|
||||
} else {
|
||||
$this->assertInstanceOf('DateTime', $result);
|
||||
$this->assertInstanceOf(\DateTime::class, $result);
|
||||
$this->assertSame($expectedDateAsString, $result->format('Y-m-d H:i:s'));
|
||||
}
|
||||
} catch (InvalidValueException $exception) {
|
||||
|
||||
Reference in new issue
Block a user