예제 #1
0
 public function testOutput()
 {
     $this->specifyConfig()->cloneOnly(['excel', 'path']);
     $excel = new \Excel();
     $excel->worksheet('Worksheet', ['-']);
     $path = $this->savePath;
     $this->specify('save .xls to file', function () use($excel, $path) {
         $isExported = $excel->export('export.xls', $path);
         $this->assertTrue($isExported);
         $this->assertFileExists($path . 'export.xls');
     });
     $this->specify('save .xlsx to file', function () use($excel, $path) {
         $isExported = $excel->export('export.xlsx', $path);
         $this->assertTrue($isExported);
         $this->assertFileExists($path . 'export.xlsx');
     });
     $this->specify('save .html to file', function () use($excel, $path) {
         $isExported = $excel->export('export.html', $path);
         $this->assertTrue($isExported);
         $this->assertFileExists($path . 'export.html');
     });
     $this->specify('save .csv to file', function () use($excel, $path) {
         $isExported = $excel->export('export.csv', $path);
         $this->assertTrue($isExported);
         $this->assertFileExists($path . 'export.csv');
     });
     $this->specify('save .csv to not existing dir', function () use($excel, $path) {
         $isExported = $excel->export('export.csv', '/pmt/');
         $this->assertFalse($isExported);
         $this->assertFileNotExists('/pmt/export.csv');
     });
     $isExported = $excel->export();
     $this->assertTrue($isExported);
     $this->assertNotEmpty(ob_get_contents());
 }