diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-08-20 08:34:35 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-08-20 08:34:35 +0200 |
| commit | 45c0aa447e02c80bd21a23245574231a110cf5a1 (patch) | |
| tree | b801de455f164afbf40fbbc995ab9751163eee84 /ext/spl/tests | |
| parent | 3365f28adf90110ca7475df889720fc244820f4b (diff) | |
| download | php-45c0aa447e02c80bd21a23245574231a110cf5a1.tar.gz | |
Imported Upstream version 5.4.6upstream/5.4.6
Diffstat (limited to 'ext/spl/tests')
35 files changed, 762 insertions, 4 deletions
diff --git a/ext/spl/tests/SplFileObject_current_basic.phpt b/ext/spl/tests/SplFileObject_current_basic.phpt new file mode 100644 index 000000000..d3f4802a5 --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::current basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +echo $s->current(); + +?> +--EXPECT-- +<?php diff --git a/ext/spl/tests/SplFileObject_current_error001.phpt b/ext/spl/tests/SplFileObject_current_error001.phpt new file mode 100644 index 000000000..23c126648 --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_error001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::current variation error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); + +echo $s->current('foo'); +?> +--EXPECTF-- +Warning: SplFileObject::current() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_current_variation001.phpt b/ext/spl/tests/SplFileObject_current_variation001.phpt new file mode 100644 index 000000000..0cc588a7f --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_variation001.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::current variation +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); + +echo $s->current(); +echo $s->current(); +?> +--EXPECT-- +//line 3 +//line 3 diff --git a/ext/spl/tests/SplFileObject_getchildren_basic.phpt b/ext/spl/tests/SplFileObject_getchildren_basic.phpt new file mode 100644 index 000000000..065e8eae4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_basic.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::getchildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +var_dump($s->getChildren()); + +?> +--EXPECT-- +NULL diff --git a/ext/spl/tests/SplFileObject_getchildren_error001.phpt b/ext/spl/tests/SplFileObject_getchildren_error001.phpt new file mode 100644 index 000000000..9c17a8297 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_error001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::getchildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->getChildren('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::getChildren() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_getflags_basic.phpt b/ext/spl/tests/SplFileObject_getflags_basic.phpt new file mode 100644 index 000000000..5addadf38 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::getFlags basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); +var_dump($fo->getFlags()); +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECT-- +int(1) diff --git a/ext/spl/tests/SplFileObject_getflags_error001.phpt b/ext/spl/tests/SplFileObject_getflags_error001.phpt new file mode 100644 index 000000000..1602f8888 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_error001.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::getFlags error 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + + +$fo = new SplFileObject('testdata.csv'); +$fo->setFlags(SplFileObject::READ_CSV); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); + +var_dump($fo->getFlags()); + +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECT-- +int(1) diff --git a/ext/spl/tests/SplFileObject_getflags_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt new file mode 100644 index 000000000..e2c8255f4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_error002.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::getFlags error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze@gmail.com> +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); +$fo->setFlags(SplFileObject::READ_CSV); + +$fo->getFlags('fake'); + +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::getFlags() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_getflags_variation001.phpt b/ext/spl/tests/SplFileObject_getflags_variation001.phpt new file mode 100644 index 000000000..640de0351 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_variation001.phpt @@ -0,0 +1,29 @@ +--TEST-- +SPL: SplFileObject::getFlags +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +$fo = new SplFileObject(__FILE__); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::READ_AHEAD); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::SKIP_EMPTY); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::READ_CSV); +var_dump($fo->getFlags()); + +?> +--EXPECT-- +int(1) +int(2) +int(4) +int(8) diff --git a/ext/spl/tests/SplFileObject_haschildren_basic.phpt b/ext/spl/tests/SplFileObject_haschildren_basic.phpt new file mode 100644 index 000000000..1ce00bfd4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_basic.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::haschildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +var_dump($s->hasChildren()); + +?> +--EXPECT-- +bool(false) diff --git a/ext/spl/tests/SplFileObject_haschildren_error001.phpt b/ext/spl/tests/SplFileObject_haschildren_error001.phpt new file mode 100644 index 000000000..0c4e1de3b --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_error001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::haschildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->hasChildren('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::hasChildren() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_key_basic.phpt b/ext/spl/tests/SplFileObject_key_basic.phpt new file mode 100644 index 000000000..4081d314e --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::key basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(3); +echo $s->key(); +?> +--EXPECT-- +3 diff --git a/ext/spl/tests/SplFileObject_key_error001.phpt b/ext/spl/tests/SplFileObject_key_error001.phpt new file mode 100644 index 000000000..b0834f002 --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error001.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(12); +$s->next(); +var_dump($s->key()); +var_dump($s->valid()); +?> +--EXPECT-- +int(13) +bool(false) diff --git a/ext/spl/tests/SplFileObject_key_error002.phpt b/ext/spl/tests/SplFileObject_key_error002.phpt new file mode 100644 index 000000000..8fc9b7fef --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error002.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(120); +$s->next(); +var_dump($s->key()); +var_dump($s->valid()); +?> +--EXPECT-- +int(13) +bool(false) diff --git a/ext/spl/tests/SplFileObject_key_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt new file mode 100644 index 000000000..7568cf55f --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error003.phpt @@ -0,0 +1,15 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Erwin Poeze <erwin.poeze AT gmail.com> +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->key(3); +?> +--EXPECTF-- +Warning: SplFileObject::key() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_next_basic.phpt b/ext/spl/tests/SplFileObject_next_basic.phpt new file mode 100644 index 000000000..59dc7ab58 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::next basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +echo $s->current(); +$s->next(); + +echo $s->current(); + +?> +--EXPECT-- +<?php +//line 2 diff --git a/ext/spl/tests/SplFileObject_next_variation001.phpt b/ext/spl/tests/SplFileObject_next_variation001.phpt new file mode 100644 index 000000000..34771dd52 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_variation001.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::next variation 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(13); +echo $s->current(); + +$s->next(); +echo $s->current(); +var_dump($s->valid()); +?> +--EXPECT-- +?> +bool(false) diff --git a/ext/spl/tests/SplFileObject_next_variation002.phpt b/ext/spl/tests/SplFileObject_next_variation002.phpt new file mode 100644 index 000000000..d48ff8c22 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_variation002.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::next variation 002, read ahead +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); +echo $s->current(); +$s->next(); +echo $s->current(); + +$s->setFlags(SplFileObject::READ_AHEAD); + +$s->seek(2); +echo $s->current(); +$s->next(); +echo $s->current(); +?> +--EXPECT-- +//line 3 +//line 4 +//line 3 +//line 4 diff --git a/ext/spl/tests/SplFileObject_rewind_basic.phpt b/ext/spl/tests/SplFileObject_rewind_basic.phpt new file mode 100644 index 000000000..331c587e4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::rewind basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(3); + +$s->rewind(); +echo $s->current(); +?> +--EXPECT-- +<?php diff --git a/ext/spl/tests/SplFileObject_rewind_error001.phpt b/ext/spl/tests/SplFileObject_rewind_error001.phpt new file mode 100644 index 000000000..bdb3301e6 --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_error001.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::rewind() with a parameter. +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); + +$fo->rewind( "invalid" ); + +?> +--EXPECTF-- +Warning: SplFileObject::rewind() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_rewind_variation001.phpt b/ext/spl/tests/SplFileObject_rewind_variation001.phpt new file mode 100644 index 000000000..d835c443d --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_variation001.phpt @@ -0,0 +1,28 @@ +--TEST-- +SPL: SplFileObject::rewind variation 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(15); +echo $s->current(); +$s->next(); +echo $s->current(); +var_dump($s->valid()); +$s->rewind(); +var_dump($s->valid()); +echo $s->current(); +?> +--EXPECT-- +?> +bool(false) +bool(true) +<?php diff --git a/ext/spl/tests/SplFileObject_seek_basic.phpt b/ext/spl/tests/SplFileObject_seek_basic.phpt new file mode 100644 index 000000000..7106f70cc --- /dev/null +++ b/ext/spl/tests/SplFileObject_seek_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::seek basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(2); +echo $s->current(); +?> +--EXPECT-- +//line 3 diff --git a/ext/spl/tests/SplFileObject_seek_error002.phpt b/ext/spl/tests/SplFileObject_seek_error002.phpt new file mode 100644 index 000000000..057c8d325 --- /dev/null +++ b/ext/spl/tests/SplFileObject_seek_error002.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::seek error 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(20); +echo $s->current(); +?> +--EXPECT-- diff --git a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt new file mode 100644 index 000000000..b2630606e --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::setCsvControl basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', '\'', '/'); +foreach ($s as $row) { + list($fruit, $quantity) = $row; + echo "$fruit : $quantity\n"; +} +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECT-- +groene appelen : 10 +gele bananen : 20 +rode kersen : 30 + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt new file mode 100644 index 000000000..f582a4a89 --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('||'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): delimiter must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt new file mode 100644 index 000000000..bcfd9c4dd --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', 'two'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): enclosure must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt new file mode 100644 index 000000000..8b1f54d5a --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', '\'', 'three'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): escape must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt new file mode 100644 index 000000000..7aaf8a3fe --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::setCsvControl variation 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +"groene appelen",10 +"gele bananen",20 +"rode kersen",30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl(); +foreach ($s as $row) { + list($fruit, $quantity) = $row; + echo "$fruit : $quantity\n"; +} +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECT-- +groene appelen : 10 +gele bananen : 20 +rode kersen : 30 + diff --git a/ext/spl/tests/bug61527.phpt b/ext/spl/tests/bug61527.phpt new file mode 100644 index 000000000..ab13c6954 --- /dev/null +++ b/ext/spl/tests/bug61527.phpt @@ -0,0 +1,92 @@ +--TEST-- +Bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to the end) +--FILE-- +<?php +$ao = new ArrayObject(array()); +$ai = $ao->getIterator(); + +/* testing empty array, should no notice at all */ +$ai->next(); +var_dump($ai->key()); +var_dump($ai->current()); + +/* testing array changing */ +$ao2 = new ArrayObject(array(1 => 1, 2, 3, 4, 5)); +$ai2 = $ao2->getIterator(); + +$ao2->offsetUnset($ai2->key()); +$ai2->next(); + +/* now point to 2 */ +$ao2->offsetUnset($ai2->key()); +var_dump($ai2->key()); + +/* now point to 3 */ +$ao2->offsetUnset($ai2->key()); +var_dump($ai2->current()); + +$ai2->next(); +var_dump($ai2->key()); +var_dump($ai2->current()); + +/* should be at the end and no notice */ +$ai2->next(); +var_dump($ai2->key()); +var_dump($ai2->current()); + +$ai2->rewind(); +$ai2->next(); +$ai2->next(); +/* should reached the end */ +var_dump($ai2->next()); +var_dump($ai2->key()); + +/* testing RecursiveArrayIterator */ +$ao3 = new ArrayObject(array(), NULL, 'RecursiveArrayIterator'); +$ai3 = $ao3->getIterator(); + +var_dump($ai3->getChildren()); + +$ao4 = new ArrayObject(array(1, 2), NULL, 'RecursiveArrayIterator'); +$ai4 = $ao4->getIterator(); + +$ai4->next(); +$ai4->next(); +$ai4->next(); +var_dump($ai4->hasChildren()); + +$ai4->rewind(); +$ao4->offsetUnset($ai4->key()); +var_dump($ai4->hasChildren()); + +$ao4->offsetUnset($ai4->key()); +var_dump($ai4->getChildren()); +?> +==DONE== +<?php exit(0); ?> +--EXPECTF-- +NULL +NULL + +Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d + +Notice: ArrayIterator::key(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL + +Notice: ArrayIterator::current(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL +int(5) +int(5) +NULL +NULL +NULL +NULL +NULL +bool(false) + +Notice: RecursiveArrayIterator::hasChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +bool(false) + +Notice: RecursiveArrayIterator::getChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL +==DONE== diff --git a/ext/spl/tests/bug62433.phpt b/ext/spl/tests/bug62433.phpt index 86b5df838..bfb3568ba 100644 --- a/ext/spl/tests/bug62433.phpt +++ b/ext/spl/tests/bug62433.phpt @@ -5,11 +5,11 @@ Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. a $dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__))); $ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS))); -var_dump(in_array(__DIR__ . '/.', $dots)); -var_dump(in_array(__DIR__ . '/..', $dots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $dots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $dots)); -var_dump(in_array(__DIR__ . '/.', $ndots)); -var_dump(in_array(__DIR__ . '/..', $ndots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $ndots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $ndots)); ?> --EXPECT-- bool(true) diff --git a/ext/spl/tests/bug62616.phpt b/ext/spl/tests/bug62616.phpt new file mode 100644 index 000000000..4e4be9449 --- /dev/null +++ b/ext/spl/tests/bug62616.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault) +--FILE-- +<?php +$ai = new ArrayIterator(array(0,1)); + +var_dump($ai->count()); + +$ii = new IteratorIterator($ai); + +var_dump($ii->count()); +?> +--EXPECTF-- +int(2) +int(2) diff --git a/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt new file mode 100644 index 000000000..3c0c9eebd --- /dev/null +++ b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getMaxLineLen error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->getMaxLineLen('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::getMaxLineLen() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt new file mode 100644 index 000000000..6bfdfdcf5 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt @@ -0,0 +1,17 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 001() +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +try { + $s->setMaxLineLen(-1); +} +catch (DomainException $e) { + echo 'DomainException thrown'; +} + +?> +--EXPECT-- +DomainException thrown diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt new file mode 100644 index 000000000..dad59fca5 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->setMaxLineLen(); + +?> +--EXPECTF-- +Warning: SplFileObject::setMaxLineLen() expects exactly 1 parameter, 0 given in %s on line %d diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt new file mode 100644 index 000000000..8dc50d5fc --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->setMaxLineLen('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::setMaxLineLen() expects parameter 1 to be long, string given in %s on line %d |
