Skip to content

Commit 0873648

Browse files
committed
- New tests (testfest NorthWestUG)
1 parent 941ac63 commit 0873648

File tree

104 files changed

+2055
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2055
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
DirectoryIterator::getBasename() - Basic Test
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
$targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
8+
mkdir($targetDir);
9+
touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
10+
$dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR);
11+
while(!$dir->isFile()) {
12+
$dir->next();
13+
}
14+
echo $dir->getBasename('.txt');
15+
?>
16+
--CLEAN--
17+
<?php
18+
$targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
19+
unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
20+
rmdir($targetDir);
21+
?>
22+
--EXPECTF--
23+
getBasename_test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
DirectoryIterator::getBasename() - Pass unexpected array
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
$targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
8+
mkdir($targetDir);
9+
touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
10+
$dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR);
11+
while(!$dir->isFile()) {
12+
$dir->next();
13+
}
14+
echo $dir->getBasename(array());
15+
?>
16+
--CLEAN--
17+
<?php
18+
$targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
19+
unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
20+
rmdir($targetDir);
21+
?>
22+
--EXPECTF--
23+
Warning: DirectoryIterator::getBasename() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d

ext/spl/tests/SplArray_fromArray.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Check that SplArray::fromArray will not allow integer overflows
3+
--CREDITS--
4+
Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
5+
--FILE--
6+
<?php
7+
$array = array(PHP_INT_MAX => 'foo');
8+
$splArray = new SplFixedArray();
9+
10+
try {
11+
$splArray->fromArray($array);
12+
} catch (Exception $e) {
13+
echo $e->getMessage();
14+
}
15+
?>
16+
--EXPECT--
17+
integer overflow detected
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SplDoublyLinkedList::bottom() - pass in an unexpected array parameter
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
8+
$list = new SplDoublyLinkedList();
9+
$list->push("top");
10+
$list->bottom(array());
11+
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SplDoublyLinkedList::bottom() - pass in an unexpected float parameter
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
8+
$list = new SplDoublyLinkedList();
9+
$list->push("top");
10+
$list->bottom(3.14159);
11+
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SplDoublyLinkedList::bottom() - pass in an unexpected integer parameter
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
8+
$list = new SplDoublyLinkedList();
9+
$list->push("top");
10+
$list->bottom(45);
11+
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SplDoublyLinkedList::bottom() - pass in an unexpected null parameter
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Adrian Hardy
5+
--FILE--
6+
<?php
7+
8+
$list = new SplDoublyLinkedList();
9+
$list->push("top");
10+
$list->bottom(null);
11+
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList::count fails if parameter passed in
3+
--CREDITS--
4+
Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
9+
$c = $list->count('foo');
10+
?>
11+
--EXPECTF--
12+
Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Create a SplDoublyLinkedList, call count() and pass a SplDoublyLinkedList object as the parameter.
3+
--CREDITS--
4+
Philip Norton philipnorton42@gmail.com
5+
--FILE--
6+
<?php
7+
$dll = new SplDoublyLinkedList(2);
8+
$dll->count(new SplDoublyLinkedList(2));
9+
?>
10+
--EXPECTF--
11+
Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line %d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
SplDoublyLinkedList getIteratorMode
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Lorna Mitchell
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
var_dump($list->current());
9+
?>
10+
--EXPECT--
11+
NULL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Run current() function on an empty SplDoublyLinkedList.
3+
--CREDITS--
4+
Philip Norton philipnorton42@gmail.com
5+
--FILE--
6+
<?php
7+
8+
$list = new SplDoublyLinkedList();
9+
var_dump($list->current());
10+
11+
?>
12+
--EXPECT--
13+
NULL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList returns debug info when print_r is used.
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
5+
--FILE--
6+
<?php
7+
// Create a new Doubly Linked List
8+
$dll = new SplDoublyLinkedList();
9+
10+
// Add some items to the list
11+
$dll->push(1);
12+
$dll->push(2);
13+
$dll->push(3);
14+
15+
// Check the debug info
16+
print_r($dll);
17+
?>
18+
--EXPECT--
19+
SplDoublyLinkedList Object
20+
(
21+
[flags:SplDoublyLinkedList:private] => 0
22+
[dllist:SplDoublyLinkedList:private] => Array
23+
(
24+
[0] => 1
25+
[1] => 2
26+
[2] => 3
27+
)
28+
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
SplDoublyLinkedList getIteratorMode
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Lorna Mitchell
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
9+
echo $list->getIteratorMode();
10+
?>
11+
--EXPECT--
12+
0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
SplDoublyLinkedList getIteratorMode with an unexpected parameter
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Lorna Mitchell
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
$list->getIteratorMode(24);
9+
?>
10+
--EXPECTF--
11+
Warning: SplDoublyLinkedList::getIteratorMode() expects exactly 0 parameters, 1 given in %s on line %d
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
5+
--FILE--
6+
<?php
7+
// Create a new Doubly Linked List
8+
$dll = new SplDoublyLinkedList();
9+
10+
var_dump($dll->isEmpty("test"));
11+
?>
12+
--EXPECTF--
13+
Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
14+
NULL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList->isEmpty() correctly returns true for an empty list.
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
5+
--FILE--
6+
<?php
7+
// Create a new Doubly Linked List
8+
$dll = new SplDoublyLinkedList();
9+
10+
var_dump($dll->isEmpty());
11+
?>
12+
--EXPECT--
13+
bool(true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
5+
--FILE--
6+
<?php
7+
// Create a new Doubly Linked List
8+
$dll = new SplDoublyLinkedList();
9+
10+
// Add some items to the list
11+
$dll->push(1);
12+
$dll->push(2);
13+
$dll->push(3);
14+
//var_dump($dll);
15+
16+
var_dump($dll->isEmpty("test"));
17+
?>
18+
--EXPECTF--
19+
Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
20+
NULL
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList->isEmpty() correctly returns true for a non-empty list.
3+
--CREDITS--
4+
PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
5+
--FILE--
6+
<?php
7+
// Create a new Doubly Linked List
8+
$dll = new SplDoublyLinkedList();
9+
10+
// Add some items to the list
11+
$dll->push(1);
12+
$dll->push(2);
13+
$dll->push(3);
14+
//var_dump($dll);
15+
16+
var_dump($dll->isEmpty());
17+
?>
18+
--EXPECT--
19+
bool(false)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Check that SplDoublyLinkedList can traverse backwards
3+
--CREDITS--
4+
Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
9+
$list->push('o');
10+
$list->push('o');
11+
$list->push('f');
12+
13+
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
14+
15+
$list->rewind();
16+
17+
while ($tmp = $list->current()) {
18+
echo $tmp;
19+
$list->next();
20+
}
21+
?>
22+
--EXPECT--
23+
foo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
SPL SplDoublyLinkedList offsetExists displays warning and returns null on no parameters
3+
--CREDITS--
4+
PHPNW TestFest 2009 - Ben Longden
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
$a = $list->offsetExists();
9+
if(is_null($a)) {
10+
echo 'PASS';
11+
}
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::offsetExists() expects exactly 1 parameter, 0 given in %s on line %d
15+
PASS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
SPL SplDoublyLinkedList offsetExists returns correct values
3+
--CREDITS--
4+
PHPNW TestFest 2009 - Ben Longden
5+
--FILE--
6+
<?php
7+
$list = new SplDoublyLinkedList();
8+
9+
// Push two values onto the list
10+
$list->push('abc');
11+
$list->push('def');
12+
13+
// Validate that we can see the first value
14+
if($list->offsetExists(0) === true) {
15+
echo "PASS\n";
16+
}
17+
18+
// Validate that we can see the second value
19+
if($list->offsetExists(1) === true) {
20+
echo "PASS\n";
21+
}
22+
23+
// Check that there is no third value
24+
if($list->offsetExists(2) === false) {
25+
echo "PASS\n";
26+
}
27+
?>
28+
--EXPECTF--
29+
PASS
30+
PASS
31+
PASS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
SplDoublyLinkedList::offsetGet() with no parameter passed.
3+
--CREDITS--
4+
PHPNW Test Fest 2009 - Jordan Hatch
5+
--FILE--
6+
<?php
7+
8+
$array = new SplDoublyLinkedList( );
9+
10+
$get = $array->offsetGet();
11+
12+
?>
13+
--EXPECTF--
14+
Warning: SplDoublyLinkedList::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d

0 commit comments

Comments
 (0)