Exemplo n.º 1
0
    public function testExportCustomControls()
    {
        $csv = new CsvExport();
        $response = $csv->__invoke('foo.csv', $this->header, $this->records, null, ';', "'");
        $content = <<<CSV
Year;Make;Model;Description;Price
1997;Ford;E350;'ac, abs, moon';3000.00

CSV;
        $this->assertEquals($content, $response->getContent());
    }
Exemplo n.º 2
0
    public function testImport()
    {
        $csv = new CsvExport();
        $header = array('Year', 'Make', 'Model', 'Description', 'Price');
        $records = array(array('1997', 'Ford', 'E350', 'ac, abs, moon', '3000.00'));
        $response = $csv->__invoke('foo.csv', $header, $records);
        $type = $response->getHeaders()->get('Content-Type')->getFieldValue();
        $this->assertEquals('text/csv', $type);
        $disposition = $response->getHeaders()->get('Content-Disposition')->getFieldValue();
        $this->assertEquals('attachment;filename="foo.csv"', $disposition);
        $content = <<<CSV
Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00

CSV;
        $this->assertEquals($content, $response->getContent());
    }