make row tests pass

This commit is contained in:
madflow 2017-07-30 21:17:33 +02:00
parent 23de4b4117
commit 7c7376e151

View File

@ -21,24 +21,35 @@ class RowTest extends TestCase
return $cellMock; return $cellMock;
} }
protected function rowManagerMock()
{
$rowManagerMock = $this
->getMockBuilder('Box\Spout\Writer\Common\Manager\RowManager')
->disableOriginalConstructor();
return $rowManagerMock;
}
public function testValidInstance() public function testValidInstance()
{ {
$this->assertInstanceOf('Box\Spout\Writer\Common\Entity\Row', new Row()); $this->assertInstanceOf(
$this->assertInstanceOf('Box\Spout\Writer\Common\Entity\Row', new Row([])); 'Box\Spout\Writer\Common\Entity\Row',
$this->assertInstanceOf('Box\Spout\Writer\Common\Entity\Row', new Row([], $this->styleMock()->getMock())); new Row([],
$this->assertInstanceOf('Box\Spout\Writer\Common\Entity\Row', new Row([$this->cellMock()->getMock()])); null,
$this->rowManagerMock()->getMock()
)
);
} }
public function testSetCells() public function testSetCells()
{ {
$o = new Row(); $o = new Row([], null, $this->rowManagerMock()->getMock());
$o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]); $o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]);
$this->assertEquals(2, count($o->getCells())); $this->assertEquals(2, count($o->getCells()));
} }
public function testSetCellsResets() public function testSetCellsResets()
{ {
$o = new Row(); $o = new Row([], null, $this->rowManagerMock()->getMock());
$o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]); $o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]);
$this->assertEquals(2, count($o->getCells())); $this->assertEquals(2, count($o->getCells()));
$o->setCells([$this->cellMock()->getMock()]); $o->setCells([$this->cellMock()->getMock()]);
@ -47,7 +58,7 @@ class RowTest extends TestCase
public function testGetCells() public function testGetCells()
{ {
$o = new Row(); $o = new Row([], null, $this->rowManagerMock()->getMock());
$this->assertEquals(0, count($o->getCells())); $this->assertEquals(0, count($o->getCells()));
$o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]); $o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]);
$this->assertEquals(2, count($o->getCells())); $this->assertEquals(2, count($o->getCells()));
@ -55,7 +66,7 @@ class RowTest extends TestCase
public function testAddCell() public function testAddCell()
{ {
$o = new Row(); $o = new Row([], null, $this->rowManagerMock()->getMock());
$o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]); $o->setCells([$this->cellMock()->getMock(), $this->cellMock()->getMock()]);
$this->assertEquals(2, count($o->getCells())); $this->assertEquals(2, count($o->getCells()));
$o->addCell($this->cellMock()->getMock()); $o->addCell($this->cellMock()->getMock());
@ -64,7 +75,7 @@ class RowTest extends TestCase
public function testFluentInterface() public function testFluentInterface()
{ {
$o = new Row(); $o = new Row([], null, $this->rowManagerMock()->getMock());
$o $o
->addCell($this->cellMock()->getMock()) ->addCell($this->cellMock()->getMock())
->setStyle($this->styleMock()->getMock()) ->setStyle($this->styleMock()->getMock())