xref: /PHP-8.0/ext/spl/tests/gh8121.phpt (revision 1d9a1f9b)
1--TEST--
2GH-8121 (SplFileObject - seek and key with csv file inconsistent)
3--FILE--
4<?php
5$flagss = [
6    SplFileObject::READ_AHEAD | SplFileObject::READ_CSV | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE,
7    SplFileObject::READ_AHEAD |                           SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE,
8                                                          SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE,
9];
10foreach ($flagss as $flags) {
11    $file = new SplFileObject(__DIR__ . "/gh8121.csv", "r");
12    echo "flags: $flags\n";
13    $file->setFlags($flags);
14    $file->seek(0);
15    var_dump($file->key());
16    $file->seek(1);
17    var_dump($file->key());
18    $file->seek(2);
19    var_dump($file->key());
20    $file->seek(3);
21    var_dump($file->key());
22}
23?>
24--EXPECT--
25flags: 15
26int(0)
27int(1)
28int(2)
29int(3)
30flags: 7
31int(0)
32int(1)
33int(2)
34int(3)
35flags: 5
36int(0)
37int(1)
38int(2)
39int(3)
40