Beispiel #1
0
 public function testOutputGivesNoSideEffects()
 {
     $this->adapter->validateOutput();
     ob_start();
     $buffer = $this->adapter->output();
     $sideEffectsBuffer = ob_get_clean();
     $this->assertNotEmpty($buffer);
     $this->assertEmpty($sideEffectsBuffer);
 }
Beispiel #2
0
 public function testOutputWithoutHeaders()
 {
     $this->config->setExtraSettings(['skipHeaders' => true]);
     $buffer = $this->adapter->output();
     $sampleCsv = 'zażółć gęślą,jaźń';
     $this->assertSame($sampleCsv, $buffer);
 }
Beispiel #3
0
 public function testMissingTemplateSettings()
 {
     $this->config->setTemplate(null);
     try {
         $this->adapter->validateOutput();
         $this->fail();
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Vegas\\Exporter\\Adapter\\Exception\\TemplateNotSetException', $e);
     }
 }
Beispiel #4
0
    public function testUseObjectDataForOutput()
    {
        $object = new \stdClass();
        $object->bar = 'zażółć gęślą';
        $object->foo = 'jaźń';
        $this->config->setHeaders(['foo', 'bar', 'empty']);
        $this->config->setData([$object]);
        $buffer = $this->adapter->output();
        $prettyPrintXml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <item>
    <foo>jaźń</foo>
    <bar>zażółć gęślą</bar>
    <empty></empty>
  </item>
</root>
XML;
        $this->assertSame($prettyPrintXml, rtrim($buffer, PHP_EOL));
    }
Beispiel #5
0
 /**
  * Saves export output under specified filepath without downloading.
  * Proxied via __call() method
  * @param AdapterInterface $adapter
  */
 protected function save(AdapterInterface $adapter)
 {
     $output = $adapter->output();
     $filename = $this->config->getFilename() . $adapter->getExtension();
     $filepath = implode(DIRECTORY_SEPARATOR, [$this->config->getOutputDir(), $filename]);
     $file = fopen($filepath, 'wb');
     fwrite($file, $output);
     fclose($file);
 }