<?php

namespace Camspiers\StatisticalClassifier\DataSource;

use org\bovigo\vfs\vfsStream;

/**
 * Generated by PHPUnit_SkeletonGenerator 1.2.0 on 2013-04-13 at 17:34:17.
 */
class CSVTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var
     */
    protected $object;
    /**
     * @var
     */
    protected $csv;
    /**
     * @var
     */
    protected $data;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        vfsStream::setup();
        $this->data = array(
            'test' => array(
                'Some document'
            ),
            'test2' => array(
                'Some document'
            )
        );
        $this->csv = <<<CSV
"Document","Category"
"Some document","test"
"Some document","test2"
CSV;
        file_put_contents($url = vfsStream::url('root/read.csv'), $this->csv);
        $this->object = new CSV(
            array(
                'file' => $url,
                'document_columns' => array(
                    'Document'
                ),
                'category_column' => 'Category'
            )
        );
    }

    public function testRead()
    {
        $this->assertEquals(
            $this->data,
            $this->object->getData()
        );
    }

    public function testWrite()
    {
//        $url = vfsStream::url('root/write.csv');
//        $test = new CSV(
//            array(
//                'file' => $url,
//                'document_columns' => array(
//                    'Document'
//                ),
//                'category_column' => 'Category'
//            )
//        );
//        $test->setData($this->data);
//        $test->write();
//        $this->assertTrue(
//            file_exists($url)
//        );
//        $this->assertEquals(
//            $this->csv,
//            file_get_contents($url)
//        );
    }
}
