Example #1
0
 /**
  * @dataProvider getGetResponseTests
  */
 public function testGetResponse($format, $filename, $contentType)
 {
     $source = new ArraySourceIterator(array(array('foo' => 'bar')));
     $writer = $this->getMock('Exporter\\Writer\\TypedWriterInterface');
     $writer->expects($this->any())->method('getFormat')->willReturn('made-up');
     $writer->expects($this->any())->method('getDefaultMimeType')->willReturn('application/made-up');
     $exporter = new Exporter(array(new CsvWriter('php://output', ',', '"', '', true, true), new JsonWriter('php://output'), new XlsWriter('php://output'), new XmlWriter('php://output'), $writer));
     $response = $exporter->getResponse($format, $filename, $source);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertSame($contentType, $response->headers->get('Content-Type'));
     $this->assertSame('attachment; filename="' . $filename . '"', $response->headers->get('Content-Disposition'));
 }
 public function testBuildersGetCalled()
 {
     $workspace = $this->prophet->prophesize('\\Exporter\\Workspace');
     // Cleans up workspace
     $workspace->clean_up()->shouldBeCalled();
     // Creates the article.json file
     $workspace->write_tmp_file('article.json', \Prophecy\Argument::type('string'))->willReturn(true);
     // Creates a zipfile with the id
     $workspace->zip('article-3.zip')->willReturn(true);
     $builder1 = $this->prophet->prophesize('\\Exporter\\Builders\\Builder');
     $builder1->to_array()->shouldBeCalled();
     $builder2 = $this->prophet->prophesize('\\Exporter\\Builders\\Builder');
     $builder2->to_array()->shouldBeCalled();
     $content = new \Exporter\Exporter_Content(3, 'Title', '<p>Example content</p>');
     $exporter = new Exporter($content, $workspace->reveal());
     $exporter->initialize_builders(array('componentTextStyles' => $builder1->reveal(), 'componentLayouts' => $builder2->reveal()));
     $exporter->export();
 }