Skip to content

Commit 9708b01

Browse files
committed
- New tests (testfest NorthWestUG)
1 parent 1498bb4 commit 9708b01

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
Lines changed: 23 additions & 0 deletions
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
Lines changed: 23 additions & 0 deletions
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
Lines changed: 17 additions & 0 deletions
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
Lines changed: 14 additions & 0 deletions
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
Lines changed: 14 additions & 0 deletions
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
Lines changed: 14 additions & 0 deletions
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
Lines changed: 14 additions & 0 deletions
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
Lines changed: 12 additions & 0 deletions
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
Lines changed: 11 additions & 0 deletions
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
Lines changed: 11 additions & 0 deletions
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

0 commit comments

Comments
 (0)