diff options
author | Marcus Boerger <helly@php.net> | 2005-05-03 21:11:26 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-05-03 21:11:26 +0000 |
commit | 287864a611ccf1023221ddbcb598abe1fbdfea72 (patch) | |
tree | a364dc301e6786a74a888777ee4e00cb544fab9f /ext/spl/tests/fileobject_001.phpt | |
parent | b3a8a5058184cb173c7fce385ef94f6bcbc6459e (diff) | |
download | php-git-287864a611ccf1023221ddbcb598abe1fbdfea72.tar.gz |
- Change FileObject's line counting to be zero based
- Make FileObject implement SeekableIterator
- Add tests
Diffstat (limited to 'ext/spl/tests/fileobject_001.phpt')
-rwxr-xr-x | ext/spl/tests/fileobject_001.phpt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt new file mode 100755 index 0000000000..056c1e17f7 --- /dev/null +++ b/ext/spl/tests/fileobject_001.phpt @@ -0,0 +1,88 @@ +--TEST-- +SPL: FileObject::seek'ing +--FILE-- +<?php + +$o = new FileObject(dirname(__FILE__) . '/fileobject_001a.txt'); + +var_dump($o->key()); +var_dump($o->current()); +$o->setFlags(FO_DROP_NEW_LINE); +var_dump($o->key()); +var_dump($o->current()); +var_dump($o->key()); +$o->next(); +var_dump($o->key()); +var_dump($o->current()); +var_dump($o->key()); +$o->rewind(); +var_dump($o->key()); +var_dump($o->current()); +var_dump($o->key()); +$o->seek(4); +var_dump($o->key()); +var_dump($o->current()); +var_dump($o->key()); + +echo "===A===\n"; +foreach($o as $n => $l) +{ + var_dump($n, $l); +} + +echo "===B===\n"; +$o = new FileObject(dirname(__FILE__) . '/fileobject_001b.txt'); +$o->setFlags(FO_DROP_NEW_LINE); +foreach($o as $n => $l) +{ + var_dump($n, $l); +} + +?> +===DONE=== +--EXPECT-- +int(0) +string(2) "0 +" +int(0) +string(2) "0 +" +int(0) +int(1) +string(1) "1" +int(1) +int(0) +string(1) "0" +int(0) +int(4) +string(1) "4" +int(4) +===A=== +int(0) +string(1) "0" +int(1) +string(1) "1" +int(2) +string(1) "2" +int(3) +string(1) "3" +int(4) +string(1) "4" +int(5) +string(1) "5" +int(6) +string(0) "" +===B=== +int(0) +string(1) "0" +int(1) +string(1) "1" +int(2) +string(1) "2" +int(3) +string(1) "3" +int(4) +string(1) "4" +int(5) +string(1) "5" +===DONE=== |