diff options
author | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-02-10 09:47:47 +0100 |
---|---|---|
committer | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-02-10 09:47:47 +0100 |
commit | f4b09e18166c990879ef853c0f5aa44fe881ece3 (patch) | |
tree | 7c2c98afe87d68420df64e549851d5006a345a4b /test | |
parent | 6eafc3914df8ee3129cb1ef430351f8a9a3194c9 (diff) | |
download | csv-f4b09e18166c990879ef853c0f5aa44fe881ece3.zip csv-f4b09e18166c990879ef853c0f5aa44fe881ece3.tar.gz csv-f4b09e18166c990879ef853c0f5aa44fe881ece3.tar.bz2 |
improve SplFileObject flags handling
Diffstat (limited to 'test')
-rw-r--r-- | test/ControlsTest.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/ControlsTest.php b/test/ControlsTest.php index aaff9d2..0ed477c 100644 --- a/test/ControlsTest.php +++ b/test/ControlsTest.php @@ -83,10 +83,20 @@ class ControlsTest extends PHPUnit_Framework_TestCase public function testGetBomOnInputWithBOM() { - $expected = "\x00\x00\xFE\xFFjohn,doe,john.doe@example.com".PHP_EOL + $expected = Reader::BOM_UTF32_BE."john,doe,john.doe@example.com".PHP_EOL ."jane,doe,jane.doe@example.com".PHP_EOL; $reader = Reader::createFromString($expected); $this->assertSame(Reader::BOM_UTF32_BE, $reader->getInputBOM()); + $this->assertSame(Reader::BOM_UTF32_BE, $reader->getInputBOM()); + } + + public function testChangingBOMOnOutput() + { + $text = "john,doe,john.doe@example.com".PHP_EOL + ."jane,doe,jane.doe@example.com".PHP_EOL; + $reader = Reader::createFromString(Reader::BOM_UTF32_BE.$text); + $reader->setOutputBOM(Reader::BOM_UTF8); + $this->assertSame(Reader::BOM_UTF8.$text, $reader->__toString()); } /** @@ -163,9 +173,12 @@ 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_CSV, $this->csv->getFlags() & SplFileObject::READ_CSV); + $this->assertSame(SplFileObject::DROP_NEW_LINE, $this->csv->getFlags() & SplFileObject::DROP_NEW_LINE); $this->csv->setFlags(-3); } |