fread(10)); self::assertSame(10, $reader->ftell()); $reader->seek(30); self::assertSame("abcdefghij", $reader->fread(10)); self::assertSame(40, $reader->ftell()); $reader->seek(10); self::assertSame("ABCDEFGHIJ", $reader->fread(10)); self::assertSame(20, $reader->ftell()); $reader->seek(40); self::assertSame("0123456789\n", $reader->getContents()); $reader->close(); ## avec BOM $reader = new FileReader(__DIR__.'/impl/avec_bom.txt'); self::assertSame("0123456789", $reader->fread(10)); self::assertSame(10, $reader->ftell()); $reader->seek(30); self::assertSame("abcdefghij", $reader->fread(10)); self::assertSame(40, $reader->ftell()); $reader->seek(10); self::assertSame("ABCDEFGHIJ", $reader->fread(10)); self::assertSame(20, $reader->ftell()); $reader->seek(40); self::assertSame("0123456789\n", $reader->getContents()); $reader->close(); } function testCsvAutoParams() { $reader = new FileReader(__DIR__.'/impl/msexcel.csv'); self::assertSame(["nom", "prenom", "age"], $reader->fgetcsv()); self::assertSame(["clain", "jephte", "50"], $reader->fgetcsv()); self::assertNull($reader->fgetcsv()); $reader->close(); $reader = new FileReader(__DIR__.'/impl/ooffice.csv'); self::assertSame(["nom", "prenom", "age"], $reader->fgetcsv()); self::assertSame(["clain", "jephte", "50"], $reader->fgetcsv()); self::assertNull($reader->fgetcsv()); $reader->close(); $reader = new FileReader(__DIR__.'/impl/weird.tsv'); self::assertSame(["nom", "prenom", "age"], $reader->fgetcsv()); self::assertSame(["clain", "jephte", "50"], $reader->fgetcsv()); self::assertNull($reader->fgetcsv()); $reader->close(); $reader = new FileReader(__DIR__.'/impl/avec_bom.csv'); self::assertSame(["nom", "prenom", "age"], $reader->fgetcsv()); self::assertSame(["clain", "jephte", "50"], $reader->fgetcsv()); self::assertNull($reader->fgetcsv()); $reader->close(); } }