Skip to content

Commit d86262a

Browse files
committed
Add tests for extract error conditions
1 parent 5531e5a commit d86262a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test extract() function - error condition - Invalid flag argument.
3+
--FILE--
4+
<?php
5+
$a = ["1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five"];
6+
7+
try {
8+
extract($a, 10000);
9+
} catch (\Error $e) {
10+
echo $e->getMessage();
11+
}
12+
13+
?>
14+
--EXPECT--
15+
Invalid extract type
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test extract() function - error condition - Prefix flag without supplying prefix.
3+
--FILE--
4+
<?php
5+
$a = ["1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five"];
6+
7+
try {
8+
extract($a, EXTR_PREFIX_ALL);
9+
} catch (\Error $e) {
10+
echo $e->getMessage();
11+
}
12+
13+
?>
14+
--EXPECT--
15+
Specified extract type requires the prefix parameter
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test extract() function - error condition - Invalid prefix.
3+
--FILE--
4+
<?php
5+
$a = ["1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five"];
6+
7+
try {
8+
extract($a, EXTR_PREFIX_ALL, '85bogus');
9+
} catch (\Error $e) {
10+
echo $e->getMessage();
11+
}
12+
?>
13+
--EXPECT--
14+
Prefix is not a valid identifier

0 commit comments

Comments
 (0)