public function testOutputWithoutHeaders() { $this->config->setExtraSettings(['skipHeaders' => true]); $buffer = $this->adapter->output(); $sampleCsv = 'zażółć gęślą,jaźń'; $this->assertSame($sampleCsv, $buffer); }
/** * 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); }
public function testMissingTemplateSettings() { $this->config->setTemplate(null); try { $this->adapter->validateOutput(); $this->fail(); } catch (\Exception $e) { $this->assertInstanceOf('\\Vegas\\Exporter\\Adapter\\Exception\\TemplateNotSetException', $e); } }
/** * Triggers the rendering process and gets result content as string. * Use only for custom template exports. * @return string * @throws \Vegas\Mvc\Exception */ protected function getRenderedView() { try { /** @var \Phalcon\Mvc\View $view */ $view = \Phalcon\DI::getDefault()->get('view'); } catch (\Phalcon\DI\Exception $e) { throw new \Vegas\Mvc\Exception(); } $view->start(); $level = $view->getCurrentRenderLevel(); $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW); $view->render($this->config->getTemplate(), null); $view->setRenderLevel($level); $view->finish(); return $view->getContent(); }
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)); }
public function testGetSetFilenameWithDefaultValue() { $config = new ExportSettings(); $newFilename = 'new_output_filename'; $this->assertNotNull($config->getFilename()); $this->assertNotSame($newFilename, $config->getFilename()); $config->setFilename($newFilename); $this->assertSame($newFilename, $config->getFilename()); }