diff options
author | ignace nyamagana butera <nyamsprod@gmail.com> | 2015-10-21 15:46:26 +0200 |
---|---|---|
committer | ignace nyamagana butera <nyamsprod@gmail.com> | 2015-10-21 15:46:26 +0200 |
commit | 924cbde506cdeba117a161698b15885cc147ae7b (patch) | |
tree | e016d31604e2f1542e67a02e33daf20d565dc6e4 | |
parent | cbfc72a07f8c20843153efce08cb955945f3c023 (diff) | |
parent | 6f743bfa7c25e3d4180b9dd9948476194da2cfe8 (diff) | |
download | csv-924cbde506cdeba117a161698b15885cc147ae7b.zip csv-924cbde506cdeba117a161698b15885cc147ae7b.tar.gz csv-924cbde506cdeba117a161698b15885cc147ae7b.tar.bz2 |
Merge pull request #130 from thephpleague/bugfix/default-options
Bug Fix Spl Flags
-rw-r--r-- | src/AbstractCsv.php | 2 | ||||
-rw-r--r-- | src/Config/Output.php | 2 | ||||
-rw-r--r-- | test/ControlsTest.php | 5 | ||||
-rw-r--r-- | test/CsvTest.php | 4 |
4 files changed, 7 insertions, 6 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 9259fd3..d541fd3 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -94,7 +94,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate */ protected function __construct($path, $open_mode = 'r+') { - $this->flags = SplFileObject::READ_CSV | SplFileObject::DROP_NEW_LINE; + $this->flags = SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY; $this->open_mode = strtolower($open_mode); $this->path = $this->normalizePath($path); $this->initStreamFilter($this->path); diff --git a/src/Config/Output.php b/src/Config/Output.php index 991b9de..ca2cf44 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -181,8 +181,8 @@ trait Output $bom = $this->output_bom; } $csv = $this->getIterator(); - $csv->rewind(); $csv->setFlags(SplFileObject::READ_CSV); + $csv->rewind(); if (!empty($bom)) { $csv->fseek(mb_strlen($input_bom)); } diff --git a/test/ControlsTest.php b/test/ControlsTest.php index f8b8d63..97cf520 100644 --- a/test/ControlsTest.php +++ b/test/ControlsTest.php @@ -172,9 +172,10 @@ class ControlsTest extends PHPUnit_Framework_TestCase public function testSetFlags() { $this->assertSame(SplFileObject::READ_CSV, $this->csv->getFlags() & SplFileObject::READ_CSV); - $this->assertSame(SplFileObject::DROP_NEW_LINE, $this->csv->getFlags() & SplFileObject::DROP_NEW_LINE); - $this->csv->setFlags(SplFileObject::SKIP_EMPTY); $this->assertSame(SplFileObject::SKIP_EMPTY, $this->csv->getFlags() & SplFileObject::SKIP_EMPTY); + $this->assertSame(SplFileObject::READ_AHEAD, $this->csv->getFlags() & SplFileObject::READ_AHEAD); + $this->csv->setFlags(SplFileObject::DROP_NEW_LINE); + $this->assertSame(SplFileObject::DROP_NEW_LINE, $this->csv->getFlags() & SplFileObject::DROP_NEW_LINE); $this->assertSame(SplFileObject::READ_CSV, $this->csv->getFlags() & SplFileObject::READ_CSV); $this->csv->setFlags(-3); diff --git a/test/CsvTest.php b/test/CsvTest.php index 10992cb..b66d96a 100644 --- a/test/CsvTest.php +++ b/test/CsvTest.php @@ -79,7 +79,7 @@ class CsvTest extends PHPUnit_Framework_TestCase */ public function testOutputSize() { - $this->assertSame(60, $this->csv->output('test.csv')); + $this->assertSame(60, $this->csv->output(__DIR__.'/data/test.csv')); } /** @@ -87,7 +87,7 @@ class CsvTest extends PHPUnit_Framework_TestCase */ public function testOutputHeaders() { - if (! function_exists('xdebug_get_headers')) { + if (!function_exists('xdebug_get_headers')) { $this->markTestSkipped(); } $this->csv->output('test.csv'); |