summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-02-11 09:11:45 +0100
committerIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-02-11 09:11:45 +0100
commitb5c7ff95e74968f12a8284c5caf9fb8695fdf279 (patch)
tree3ca9692271235d7c771c0e01ec273c95444bb1bb
parent661e3b31375d6b7e4b068c91b8536ccdc5b2a448 (diff)
downloadcsv-b5c7ff95e74968f12a8284c5caf9fb8695fdf279.zip
csv-b5c7ff95e74968f12a8284c5caf9fb8695fdf279.tar.gz
csv-b5c7ff95e74968f12a8284c5caf9fb8695fdf279.tar.bz2
adding test for the output method
-rw-r--r--composer.json3
-rw-r--r--src/Config/Output.php1
-rw-r--r--test/CsvTest.php20
3 files changed, 22 insertions, 2 deletions
diff --git a/composer.json b/composer.json
index fc2b18b..a8057f7 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,8 @@
"ext-mbstring" : "*"
},
"require-dev": {
- "phpunit/phpunit" : "~4.0"
+ "phpunit/phpunit" : "~4.0",
+ "ext-xdebug": "~2.0"
},
"autoload": {
"psr-4": {
diff --git a/src/Config/Output.php b/src/Config/Output.php
index 8411075..9a2dd16 100644
--- a/src/Config/Output.php
+++ b/src/Config/Output.php
@@ -154,7 +154,6 @@ trait Output
*
* @param string $filename CSV downloaded name if present adds extra headers
*
- * @codeCoverageIgnore
*/
public function output($filename = null)
{
diff --git a/test/CsvTest.php b/test/CsvTest.php
index ad64826..5ee00c5 100644
--- a/test/CsvTest.php
+++ b/test/CsvTest.php
@@ -204,4 +204,24 @@ EOF;
$csv->prependStreamFilter('string.toupper');
$this->assertFalse($csv->getIterator()->getRealPath());
}
+
+ /**
+ * @runInSeparateProcess
+ */
+ public function testOutput()
+ {
+ $this->csv->output("test.csv");
+ $headers = xdebug_get_headers();
+ $this->assertSame($headers[0], "Content-Type: application/octet-stream");
+ $this->assertSame($headers[1], "Content-Transfer-Encoding: binary");
+ $this->assertSame($headers[2], "Content-Disposition: attachment; filename=\"test.csv\"");
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testFailedOutput()
+ {
+ $this->csv->output(new DateTime);
+ }
}