com php-src: addition SplFileObject tests: ext/spl/tests/SplFil eObject_getchildren_basic.phpt ext/spl/tests/SplFileObj ect_getchildren_error001.phpt
ext/spl/tests/SplFi leObject_getflags_error002.phpt ext/spl/tests/Spl FileObject_haschildren_basic.phpt ext/spl/tests/SplFile
Object_haschildren_error001.phpt ext/spl/tests/Sp lFileObject_key_error003.phpt ext/spl/tests/SplFi leObject_next_variation002.phpt ext/spl/tests/Spl
FileObject_setCsvControl_basic.p
| From: | Stanislav Malyshev | Date: | Sun, 15 Jul 2012 02:21:50 +0000 |
| Subject: | com php-src: addition SplFileObject tests: ext/spl/tests/SplFil eObject_getchildren_basic.phpt ext/spl/tests/SplFileObj ect_getchildren_error001.phpt ext/spl/tests/SplFi leObject_getflags_error002.phpt ext/spl/tests/Spl FileObject_haschildren_basic.phpt ext/spl/tests/SplFile Object_haschildren_error001.phpt ext/spl/tests/Sp lFileObject_key_error003.phpt ext/spl/tests/SplFi leObject_next_variation002.phpt ext/spl/tests/Spl FileObject_setCsvControl_basic.p |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-69594@lists.php.net to get a copy of this message | ||
Commit: 4539d799bb0c5dc73e201959b815cfe7ddcd5f05
Author: donnut <erwin.poeze@gmail.com> Sun, 24 Jun 2012 10:41:29 +0000
Committer: Stanislav Malyshev <stas@php.net> Sat, 14 Jul 2012 19:21:50 -0700
Parents: 2cb7a678a1bbd310c8c6ca2c806013df4bf10f0d
Branches: PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4539d799bb0c5dc73e201959b815cfe7ddcd5f05
Log:
addition SplFileObject tests
Changed paths:
A ext/spl/tests/SplFileObject_getchildren_basic.phpt
A ext/spl/tests/SplFileObject_getchildren_error001.phpt
A ext/spl/tests/SplFileObject_getflags_error002.phpt
A ext/spl/tests/SplFileObject_haschildren_basic.phpt
A ext/spl/tests/SplFileObject_haschildren_error001.phpt
A ext/spl/tests/SplFileObject_key_error003.phpt
A ext/spl/tests/SplFileObject_next_variation002.phpt
A ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
A ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
A ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
A ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
A ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
A ext/spl/tests/fileobject_getmaxlinelen_error001.phpt
A ext/spl/tests/fileobject_setmaxlinelen_error001.phpt
A ext/spl/tests/fileobject_setmaxlinelen_error002.phpt
A ext/spl/tests/fileobject_setmaxlinelen_error003.phpt
diff --git a/ext/spl/tests/SplFileObject_getchildren_basic.phpt b/ext/spl/tests/SplFileObject_getchildren_basic.phpt new file mode 100644 index 0000000..9c2a07e --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getchildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..b297fab --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getchildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt new file mode 100644 index 0000000..e2c8255 --- /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_haschildren_basic.phpt b/ext/spl/tests/SplFileObject_haschildren_basic.phpt new file mode 100644 index 0000000..846f23d --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::haschildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..9b0ebc3 --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::haschildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt new file mode 100644 index 0000000..7568cf5 --- /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_variation002.phpt b/ext/spl/tests/SplFileObject_next_variation002.phpt new file mode 100644 index 0000000..d48ff8c --- /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_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt new file mode 100644 index 0000000..b263060 --- /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 0000000..7190a18 --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 001 +--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('||'); +?> +--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 0000000..e3ca1fe --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 002 +--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('|', '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 0000000..8b1f54d --- /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 0000000..e41f2ff --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt @@ -0,0 +1,32 @@ +--TEST-- +SPL: SplFileObject::setCsvControl variation 001 +--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(); +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/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt new file mode 100644 index 0000000..3c0c9ee --- /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 0000000..7391369 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 001() +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..13e9ff1 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..6777ab6 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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
diff --git a/ext/spl/tests/SplFileObject_getchildren_basic.phpt b/ext/spl/tests/SplFileObject_getchildren_basic.phpt new file mode 100644 index 0000000..9c2a07e --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getchildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..b297fab --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getchildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt new file mode 100644 index 0000000..e2c8255 --- /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_haschildren_basic.phpt b/ext/spl/tests/SplFileObject_haschildren_basic.phpt new file mode 100644 index 0000000..846f23d --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::haschildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..9b0ebc3 --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::haschildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt new file mode 100644 index 0000000..7568cf5 --- /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_variation002.phpt b/ext/spl/tests/SplFileObject_next_variation002.phpt new file mode 100644 index 0000000..d48ff8c --- /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_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt new file mode 100644 index 0000000..b263060 --- /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 0000000..7190a18 --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 001 +--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('||'); +?> +--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 0000000..e3ca1fe --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 002 +--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('|', '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 0000000..8b1f54d --- /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 0000000..e41f2ff --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt @@ -0,0 +1,32 @@ +--TEST-- +SPL: SplFileObject::setCsvControl variation 001 +--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(); +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/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt new file mode 100644 index 0000000..3c0c9ee --- /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 0000000..7391369 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 001() +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..13e9ff1 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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 0000000..6777ab6 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--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