Browse Source

Improved ExporterTest

Andrej Hudec 11 years ago
parent
commit
125bc2c63f
1 changed files with 17 additions and 2 deletions
  1. 17 2
      Tests/Export/ExporterTest.php

+ 17 - 2
Tests/Export/ExporterTest.php

@@ -29,15 +29,30 @@ class ExporterTest extends \PHPUnit_Framework_TestCase
         $exporter->getResponse('foo', 'foo', $source);
     }
 
-    public function testJsonFormat()
+    /**
+     * @dataProvider getGetResponseTests
+     */
+    public function testGetResponse($format, $filename, $contentType)
     {
         $source = new ArraySourceIterator(array(
             array('foo' => 'bar')
         ));
 
         $exporter = new Exporter();
-        $response = $exporter->getResponse('json', 'foo.json', $source);
+        $response = $exporter->getResponse($format, $filename, $source);
 
         $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
+        $this->assertEquals($contentType, $response->headers->get('Content-Type'));
+        $this->assertEquals('attachment; filename='.$filename, $response->headers->get('Content-Disposition'));
+    }
+
+    public function getGetResponseTests()
+    {
+        return array(
+            array('json', 'foo.json', 'application/json'),
+            array('xml', 'foo.xml', 'text/xml'),
+            array('xls', 'foo.xls', 'application/vnd.ms-excel'),
+            array('csv', 'foo.csv', 'text/csv'),
+        );
     }
 }