public function testJsonFormat() { $source = new ArraySourceIterator(array(array('foo' => 'bar'))); $exporter = new Exporter(); $response = $exporter->getResponse('json', 'foo.json', $source); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); }
/** * @dataProvider getGetResponseTests */ public function testGetResponse($format, $filename, $contentType) { $source = new ArraySourceIterator(array(array('foo' => 'bar'))); $exporter = new Exporter(); $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')); }
/** * @dataProvider getGetResponseTests */ public function testGetResponse($format, $filename, $contentType) { $source = new ArraySourceIterator(array(array('foo' => 'bar'))); $exporter = new Exporter(); $response = $exporter->getResponse($format, $filename, $source); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); $this->assertSame($contentType, $response->headers->get('Content-Type')); // Quotes does not appear on some sonata versions. $this->assertRegExp('/attachment; filename="?' . $filename . '"?/', $response->headers->get('Content-Disposition')); }