public function testApplyTheStylesOfTheWorkbook() { $phpExcelStyle = $this->getPhpExcelStyleMock(); $phpExcelStyle->expects($this->once())->method('applyFromArray'); $phpExcel = $this->getPhpExcelMock(); $phpExcel->expects($this->once())->method('getDefaultStyle')->will($this->returnValue($phpExcelStyle)); $workbook = $this->createWorkbook($phpExcel); $workbook->addStyles(new StyleCollection([new Fill(), new Font()])); $styleWorker = $this->getStyleWorkerMock(); $styleWorker->expects($this->once())->method('convertStyles'); $writer = new Writer($this->getPhpExcelWriterInterfaceMock(), $this->getTableWorkerMock(), $this->getCellWorkerMock(), $styleWorker); $phpExcel = $writer->convert($workbook); $this->assertInstanceOf('PHPExcel', $phpExcel); }
/** * @When /^I use the writer "([^"]*)" and I write the Workbook$/ */ public function iUseTheWriterAndIWriteTheWorkbook($writer) { $styleWorker = new StyleWorker(); $cellWorker = new CellWorker($styleWorker); $labelWorker = new LabelWorker($cellWorker); $tableWorker = new TableWorker($cellWorker, $labelWorker); $writer = new Writer(new Excel5('./features/behat.xls'), $tableWorker, $cellWorker, $styleWorker); // If there isn't Sheet, there is an issue with the export // So, we add one if (0 === $this->workbook->countSheets()) { $this->workbook->addSheet(new Sheet($this->workbook)); } $phpExcel = $writer->convert($this->workbook); $writer->write($phpExcel); $this->excelOutput = (new PHPExcel_Reader_Excel5())->load('./features/behat.xls'); }