-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Additional tests for SplFileObject #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--TEST-- | ||
PDO::getAvailableDrivers basic | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo')) die('skip'); | ||
?> | ||
--FILE-- | ||
<?php | ||
print_r(PDO::getAvailableDrivers()); | ||
?> | ||
--EXPECT-- | ||
Array | ||
( | ||
[0] => sqlite | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
PDO::getAvailableDrivers error when argument supplied | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo')) die('skip'); | ||
?> | ||
--FILE-- | ||
<?php | ||
PDO::getAvailableDrivers('fakeArgument'); | ||
?> | ||
--EXPECTF-- | ||
Warning: PDO::getAvailableDrivers() expects exactly 0 parameters, 1 given in %s on line %d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
SPL: SplFileObject::current basic | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#PFZ June PHP TestFest 2012 | ||
--FILE-- | ||
<?php | ||
//line 2 | ||
//line 3 | ||
//line 4 | ||
//line 5 | ||
$s = new SplFileObject(__FILE__); | ||
echo $s->current(); | ||
|
||
?> | ||
--EXPECT-- | ||
<?php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
SPL: SplFileObject::current variation error | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
SPL: SplFileObject::current variation | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
SPL: SplFileObject::getFlags basic | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
SPL: SplFileObject::getFlags error 001 | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
SPL: SplFileObject::getFlags error 001 | ||
--CREDITS-- | ||
Erwin Poeze <[email protected]> | ||
--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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
SPL: SplFileObject::getFlags | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
SPL: SplFileObject::key basic | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
SPL: SplFileObject::key error | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
SPL: SplFileObject::key error | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
SPL: SplFileObject::next basic | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
SPL: SplFileObject::next variation 001 | ||
--CREDITS-- | ||
Ricardo Oedietram <[email protected]> | ||
Erwin Poeze <[email protected]> | ||
#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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this test assumes only sqlite driver is available?