From 382bbf7910637b593d3782bd2d6bab5411930178 Mon Sep 17 00:00:00 2001 From: Rushi Vishavadia Date: Wed, 19 Aug 2015 11:03:21 +0530 Subject: [PATCH] Unit test and reset row count to 1 --- Service/ExcelWriter.php | 2 +- Tests/Service/ExcelWriterTest.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Service/ExcelWriter.php b/Service/ExcelWriter.php index e5bfce4..64ce158 100644 --- a/Service/ExcelWriter.php +++ b/Service/ExcelWriter.php @@ -44,7 +44,7 @@ public function setup($author = '', $title = '') public function setWorksheet($index, $title) { $this->handle->createSheet($index); - $this->resetCurrentRow(0); + $this->resetCurrentRow(1); $this->handle->setActiveSheetIndex($index); $this->setSheetTitle($title); } diff --git a/Tests/Service/ExcelWriterTest.php b/Tests/Service/ExcelWriterTest.php index 08740de..559088f 100644 --- a/Tests/Service/ExcelWriterTest.php +++ b/Tests/Service/ExcelWriterTest.php @@ -56,7 +56,10 @@ public function testShouldSetCurrentWorksheet() $this->phpExcelHandleMock->expects($this->once())->method('createSheet')->with($index); $this->phpExcelHandleMock->expects($this->once())->method('setActiveSheetIndex')->with($index); - $this->buildService()->setWorksheet($index, $title); + $service = $this->buildService(); + + $service->setWorksheet($index, $title); + $this->assertAttributeEquals(1, 'currentRow', $service, 'Row should be reset to 1 when switching active sheets'); } public function testShouldWriteSingleRowHeaders()