/** * @test * @covers Plum\PlumExcel\ExcelWriter::autoDetectHeader() * @covers Plum\PlumExcel\ExcelWriter::writeItem() */ public function writeItemWritesHeaderIfAutoDetectHeaderIsTrueAndItemToExcel() { $sheet = $this->getMockWorksheet(); $sheet->shouldReceive('setCellValueByColumnAndRow')->with(0, 1, 'City')->once(); $sheet->shouldReceive('setCellValueByColumnAndRow')->with(1, 1, 'Country')->once(); $sheet->shouldReceive('setCellValueByColumnAndRow')->with(0, 2, 'Vienna')->once(); $sheet->shouldReceive('setCellValueByColumnAndRow')->with(1, 2, 'Austria')->once(); $this->excel->shouldReceive('getActiveSheet')->andReturn($sheet); $this->writer->autoDetectHeader(); $this->writer->writeItem(['City' => 'Vienna', 'Country' => 'Austria']); }