public function execute()
 {
     $writer = new CsvWriter($this->getCsvWriterOptions());
     $writer->createTempStream();
     if ($this->getHeader()) {
         $writer->writeRow($this->getHeader());
     }
     $results = $this->query->find();
     foreach ($results as $result) {
         $writer->writeRow($this->getRow($result));
     }
     $this->content = $writer->getFileContent();
     $writer->close();
     return $this;
 }
 public function testWritingTempStream()
 {
     $csvArray = array(array('nom', 'prénom', 'age'), array('Martin', 'Durand', '28'), array('Alain', 'Richard', '36'));
     $expected = 'nom,prénom,age' . "\n" . 'Martin,Durand,28' . "\n" . 'Alain,Richard,36' . "\n";
     $writer = new CsvWriter(array('delimiter' => ',', 'enclosure' => '"', 'encoding' => 'UTF-8', 'eol' => "\n", 'escape' => "\\", 'enclosing_mode' => Dialect::ENCLOSING_MINIMAL, 'escape_double' => true));
     $this->assertFalse($writer->isFileOpened());
     $this->assertInstanceOf('CSanquer\\ColibriCsv\\CsvWriter', $writer->createTempStream());
     $this->assertTrue($writer->isFileOpened());
     $this->assertInternalType('resource', $writer->getFileHandler());
     $this->assertInstanceOf('CSanquer\\ColibriCsv\\CsvWriter', $writer->writeRows($csvArray));
     $this->assertEquals($expected, $writer->getFileContent());
     $this->assertInstanceOf('CSanquer\\ColibriCsv\\CsvWriter', $writer->close());
 }