<commit_before><?php
/**
 * CSVelteTest
 *
 * @package   CSVelte Unit Tests
 * @copyright (c) 2016, <NAME> <<EMAIL>>
 * @author    <NAME> <<EMAIL>>
 */
use PHPUnit\Framework\TestCase;
use CSVelte\CSVelte;
use CSVelte\Reader;
use CSVelte\Flavor;

class CSVelteTest extends TestCase
{
    public function testGenerateReaderObject()
    {
        $reader = CSVelte::reader(__DIR__ . '/../files/banklist.csv');
        $this->assertInstanceOf(Reader::class, $reader);
    }

    public function testGenerateReaderObjectWithCustomFlavor()
    {
        $flavor = new Flavor(array('delimiter' => '!', 'header' => false));
        $reader = CSVelte::reader(__DIR__ . '/../files/banklist.csv', $flavor);
        $this->assertInstanceOf(Flavor::class, $flavor);
        $this->assertSame($flavor, $reader->getFlavor());
    }

    /**
     * @expectedException CSVelte\Exception\FileNotFoundException
     */
    public function testGenerateReaderWillThrowExceptionIfFileDoesNotExist()
    {
        $reader = CSVelte::reader(__DIR__ . '/../files/banklust.csv', $flavor);
    }

    /**
     * @todo use vfsStream lib to test that CSVelte::reader() checks for file readability
     */

     public function testCSVelteReaderCanBeUsedDirectlyInsideOfAForeachLoop()
     {
         $rows = 0;
         foreach (CSVelte::reader(__DIR__ . '/../files/banklist.csv') as $row) {
             $rows++;
         }
         $this->assertEquals(545, $rows);
     }

     public function testCSVelteReaderString()
     {
         $string = "foo,bar,baz\ncolbert,4,prez\nyou,2,silly\ntoocool,4,school\n";
         $reader = CSVelte::stringReader($string, new Flavor(array('lineTerminator' => "\n", 'header' => true)));
         $this->assertEquals($reader->current()[0], 'colbert');
     }<commit_msg>Changed the last test I committed to be compatible with PHP5.3 Refs: #47<commit_after><?php
/**
 * CSVelteTest
 *
 * @package   CSVelte Unit Tests
 * @copyright (c) 2016, <NAME> <<EMAIL>>
 * @author    <NAME> <<EMAIL>>
 */
use PHPUnit\Framework\TestCase;
use CSVelte\CSVelte;
use CSVelte\Reader;
use CSVelte\Flavor;

class CSVelteTest extends TestCase
{
    public function testGenerateReaderObject()
    {
        $reader = CSVelte::reader(__DIR__ . '/../files/banklist.csv');
        $this->assertInstanceOf(Reader::class, $reader);
    }

    public function testGenerateReaderObjectWithCustomFlavor()
    {
        $flavor = new Flavor(array('delimiter' => '!', 'header' => false));
        $reader = CSVelte::reader(__DIR__ . '/../files/banklist.csv', $flavor);
        $this->assertInstanceOf(Flavor::class, $flavor);
        $this->assertSame($flavor, $reader->getFlavor());
    }

    /**
     * @expectedException CSVelte\Exception\FileNotFoundException
     */
    public function testGenerateReaderWillThrowExceptionIfFileDoesNotExist()
    {
        $reader = CSVelte::reader(__DIR__ . '/../files/banklust.csv', $flavor);
    }

    /**
     * @todo use vfsStream lib to test that CSVelte::reader() checks for file readability
     */

     public function testCSVelteReaderCanBeUsedDirectlyInsideOfAForeachLoop()
     {
         $rows = 0;
         foreach (CSVelte::reader(__DIR__ . '/../files/banklist.csv') as $row) {
             $rows++;
         }
         $this->assertEquals(545, $rows);
     }

     public function testCSVelteReaderString()
     {
         $string = "foo,bar,baz\ncolbert,4,prez\nyou,2,silly\ntoocool,4,school\n";
         $reader = CSVelte::stringReader($string, new Flavor(array('lineTerminator' => "\n", 'header' => true)));
         $this->assertEquals($reader->current()->offsetGet('foo'), 'colbert');
     }
{'fraction_non_alphanumeric': 0.15501101321585903, 'fraction_numerical': 0.007433920704845815, 'mean_word_length': 3.1050847457627118, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5912234', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1141, 'n_words': 208}