Skip to content

Commit

Permalink
return path in export method (issue #20)
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre committed May 7, 2018
1 parent 74efc43 commit 83b2d15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Exportable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ abstract protected function getType($path);
abstract protected function setOptions(&$reader_or_writer);

/**
* @param string $path
* @param string $path
* @param callable|null $callback
*
* @return string
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Common\Exception\InvalidArgumentException
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
Expand All @@ -39,6 +39,7 @@ abstract protected function setOptions(&$reader_or_writer);
public function export($path, callable $callback = null)
{
self::exportOrDownload($path, 'openToFile', $callback);
return realpath($path) ?: $path;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/FastExcelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,19 @@ public function testIssue18()
$collection = (new FastExcel)->import(__DIR__ . '/test18.csv');
$this->assertInstanceOf(Collection::class, $collection);
}

/**
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Common\Exception\InvalidArgumentException
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
*/
public function testIssue20()
{
chdir(__DIR__);
$path = (new FastExcel($this->collection()))->export('test2.xlsx');
$this->assertEquals(__DIR__ . '/test2.xlsx', $path);
unlink($path);
}
}

0 comments on commit 83b2d15

Please sign in to comment.