add new tests

This commit is contained in:
Antony Dovgal 2006-06-27 21:10:04 +00:00
parent 29b0798cc8
commit 41ada4ba9b
16 changed files with 794 additions and 0 deletions

54
Zend/tests/001.phpt Normal file
View File

@ -0,0 +1,54 @@
--TEST--
func_num_args() tests
--FILE--
<?php
function test1() {
var_dump(func_num_args());
}
function test2($a) {
var_dump(func_num_args());
}
function test3($a, $b) {
var_dump(func_num_args());
}
test1();
test2(1);
test2();
test3(1,2);
call_user_func("test1");
call_user_func("test3", 1);
call_user_func("test3", 1, 2);
class test {
static function test1($a) {
var_dump(func_num_args());
}
}
test::test1(1);
var_dump(func_num_args());
echo "Done\n";
?>
--EXPECTF--
int(0)
int(1)
Warning: Missing argument 1 for test2(), called in %s on line %d
int(0)
int(2)
int(0)
Warning: Missing argument 2 for test3() in %s on line %d
int(1)
int(2)
int(1)
Warning: func_num_args(): Called from the global scope - no function context in %s on line %d
int(-1)
Done

108
Zend/tests/002.phpt Normal file
View File

@ -0,0 +1,108 @@
--TEST--
func_get_arg() tests
--FILE--
<?php
function test1() {
var_dump(func_get_arg(-10));
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
}
function test2($a) {
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
}
function test3($a, $b) {
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
var_dump(func_get_arg(2));
}
test1();
test1(10);
test2(1);
test2();
test3(1,2);
call_user_func("test1");
call_user_func("test3", 1);
call_user_func("test3", 1, 2);
class test {
static function test1($a) {
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
}
}
test::test1(1);
var_dump(func_get_arg(1));
echo "Done\n";
?>
--EXPECTF--
Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
bool(false)
int(10)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
int(1)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
int(1)
int(2)
Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): The argument number should be >= 0 in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 0 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
Warning: Missing argument 2 for test3() in %s on line %d
int(1)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
bool(false)
int(1)
int(2)
Warning: func_get_arg(): Argument 2 not passed to function in %s on line %d
bool(false)
int(1)
Warning: func_get_arg(): Argument 1 not passed to function in %s on line %d
bool(false)
Warning: func_get_arg(): Called from the global scope - no function context in %s on line %d
bool(false)
Done

81
Zend/tests/003.phpt Normal file
View File

@ -0,0 +1,81 @@
--TEST--
func_get_args() tests
--FILE--
<?php
function test1() {
var_dump(func_get_args());
}
function test2($a) {
var_dump(func_get_args());
}
function test3($a, $b) {
var_dump(func_get_args());
}
test1();
test1(10);
test2(1);
test2();
test3(1,2);
call_user_func("test1");
call_user_func("test3", 1);
call_user_func("test3", 1, 2);
class test {
static function test1($a) {
var_dump(func_get_args());
}
}
test::test1(1);
var_dump(func_get_args());
echo "Done\n";
?>
--EXPECTF--
array(0) {
}
array(1) {
[0]=>
int(10)
}
array(1) {
[0]=>
int(1)
}
Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
array(0) {
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(0) {
}
Warning: Missing argument 2 for test3() in %s on line %d
array(1) {
[0]=>
int(1)
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(1) {
[0]=>
int(1)
}
Warning: func_get_args(): Called from the global scope - no function context in %s on line %d
bool(false)
Done

25
Zend/tests/004.phpt Normal file
View File

@ -0,0 +1,25 @@
--TEST--
strncmp() tests
--FILE--
<?php
var_dump(strncmp("", ""));
var_dump(strncmp("", "", 100));
var_dump(strncmp("aef", "dfsgbdf", -1));
var_dump(strncmp("fghjkl", "qwer", 0));
var_dump(strncmp("qwerty", "qwerty123", 6));
var_dump(strncmp("qwerty", "qwerty123", 7));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for strncmp() in %s on line %d
NULL
int(0)
Warning: Length must be greater than or equal to 0 in %s on line %d
bool(false)
int(0)
int(0)
int(-1)
Done

27
Zend/tests/005.phpt Normal file
View File

@ -0,0 +1,27 @@
--TEST--
strcasecmp() tests
--FILE--
<?php
var_dump(strcasecmp(""));
var_dump(strcasecmp("", ""));
var_dump(strcasecmp("aef", "dfsgbdf"));
var_dump(strcasecmp("qwe", "qwer"));
var_dump(strcasecmp("qwerty", "QweRty"));
var_dump(strcasecmp("qwErtY", "qwerty"));
var_dump(strcasecmp("q123", "Q123"));
var_dump(strcasecmp("01", "01"));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for strcasecmp() in %s on line %d
NULL
int(0)
int(-3)
int(-1)
int(0)
int(0)
int(0)
int(0)
Done

31
Zend/tests/006.phpt Normal file
View File

@ -0,0 +1,31 @@
--TEST--
strncasecmp() tests
--FILE--
<?php
var_dump(strncasecmp(""));
var_dump(strncasecmp("", "", -1));
var_dump(strncasecmp("aef", "dfsgbdf", 0));
var_dump(strncasecmp("aef", "dfsgbdf", 10));
var_dump(strncasecmp("qwe", "qwer", 3));
var_dump(strncasecmp("qwerty", "QweRty", 6));
var_dump(strncasecmp("qwErtY", "qwer", 7));
var_dump(strncasecmp("q123", "Q123", 3));
var_dump(strncasecmp("01", "01", 1000));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for strncasecmp() in %s on line %d
NULL
Warning: Length must be greater than or equal to 0 in %s on line %d
bool(false)
int(0)
int(-3)
int(0)
int(0)
int(2)
int(0)
int(0)
Done

63
Zend/tests/007.phpt Normal file
View File

@ -0,0 +1,63 @@
--TEST--
each() tests
--FILE--
<?php
var_dump(each());
$var = 1;
var_dump(each($var));
$var = "string";
var_dump(each($var));
$var = array(1,2,3);
var_dump(each($var));
$var = array("a"=>1,"b"=>2,"c"=>3);
var_dump(each($var));
$a = array(1);
$a [] =&$a[0];
var_dump(each($a));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for each() in %s on line %d
NULL
Warning: Variable passed to each() is not an array or object in %s on line %d
NULL
Warning: Variable passed to each() is not an array or object in %s on line %d
NULL
array(4) {
[1]=>
int(1)
["value"]=>
int(1)
[0]=>
int(0)
["key"]=>
int(0)
}
array(4) {
[1]=>
int(1)
["value"]=>
int(1)
[0]=>
string(1) "a"
["key"]=>
string(1) "a"
}
array(4) {
[1]=>
int(1)
["value"]=>
int(1)
[0]=>
int(0)
["key"]=>
int(0)
}
Done

53
Zend/tests/008.phpt Normal file
View File

@ -0,0 +1,53 @@
--TEST--
define() tests
--FILE--
<?php
var_dump(define());
var_dump(define("TRUE"));
var_dump(define("TRUE", 1));
var_dump(define("TRUE", 1, array(1)));
var_dump(define(array(1,2,3,4,5), 1));
var_dump(define(" ", 1));
var_dump(define("[[[", 2));
var_dump(define("test const", 3));
var_dump(define("test const", 3));
var_dump(define("test", array(1)));
var_dump(define("test1", new stdclass));
var_dump(constant(" "));
var_dump(constant("[[["));
var_dump(constant("test const"));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for define() in %s on line %d
NULL
Warning: Wrong parameter count for define() in %s on line %d
NULL
bool(true)
Notice: Constant true already defined in %s on line %d
bool(false)
Notice: Array to string conversion in %s on line %d
bool(true)
bool(true)
bool(true)
bool(true)
Notice: Constant test const already defined in %s on line %d
bool(false)
Warning: Constants may only evaluate to scalar values in %s on line %d
bool(false)
Warning: Constants may only evaluate to scalar values in %s on line %d
bool(false)
int(1)
int(2)
int(3)
Done

46
Zend/tests/009.phpt Normal file
View File

@ -0,0 +1,46 @@
--TEST--
get_class() tests
--FILE--
<?php
class foo {
function bar () {
var_dump(get_class());
}
}
class foo2 extends foo {
}
foo::bar();
foo2::bar();
$f1 = new foo;
$f2 = new foo2;
$f1->bar();
$f2->bar();
var_dump(get_class());
var_dump(get_class("qwerty"));
var_dump(get_class($f1));
var_dump(get_class($f2));
echo "Done\n";
?>
--EXPECTF--
Strict Standards: Non-static method foo::bar() should not be called statically in %s on line %d
string(3) "foo"
Strict Standards: Non-static method foo::bar() should not be called statically in %s on line %d
string(3) "foo"
string(3) "foo"
string(3) "foo"
Warning: get_class() called without object from outside a class in %s on line %d
bool(false)
bool(false)
string(3) "foo"
string(4) "foo2"
Done

59
Zend/tests/010.phpt Normal file
View File

@ -0,0 +1,59 @@
--TEST--
get_parent_class() tests
--FILE--
<?php
interface i {
function test();
}
class foo implements i {
function test() {
var_dump(get_parent_class());
}
}
class bar extends foo {
function test_bar() {
var_dump(get_parent_class());
}
}
$bar = new bar;
$foo = new foo;
$foo->test();
$bar->test();
$bar->test_bar();
var_dump(get_parent_class($bar));
var_dump(get_parent_class($foo));
var_dump(get_parent_class("bar"));
var_dump(get_parent_class("foo"));
var_dump(get_parent_class("i"));
var_dump(get_parent_class(""));
var_dump(get_parent_class("[[[["));
var_dump(get_parent_class(" "));
var_dump(get_parent_class(new stdclass));
var_dump(get_parent_class(array()));
var_dump(get_parent_class(1));
echo "Done\n";
?>
--EXPECTF--
bool(false)
bool(false)
string(3) "foo"
string(3) "foo"
bool(false)
string(3) "foo"
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
Done

89
Zend/tests/011.phpt Normal file
View File

@ -0,0 +1,89 @@
--TEST--
property_exists() tests
--FILE--
<?php
class foo {
public $pp1 = 1;
private $pp2 = 2;
protected $pp3 = 3;
function bar() {
var_dump(property_exists("foo","pp1"));
var_dump(property_exists("foo","pp2"));
var_dump(property_exists("foo","pp3"));
}
}
class bar extends foo {
function test() {
var_dump(property_exists("foo","pp1"));
var_dump(property_exists("foo","pp2"));
var_dump(property_exists("foo","pp3"));
}
}
var_dump(property_exists());
var_dump(property_exists(""));
var_dump(property_exists("foo","pp1"));
var_dump(property_exists("foo","pp2"));
var_dump(property_exists("foo","pp3"));
var_dump(property_exists("foo","nonexistent"));
var_dump(property_exists("fo","nonexistent"));
var_dump(property_exists("foo",""));
var_dump(property_exists("","test"));
var_dump(property_exists("",""));
$foo = new foo;
var_dump(property_exists($foo,"pp1"));
var_dump(property_exists($foo,"pp2"));
var_dump(property_exists($foo,"pp3"));
var_dump(property_exists($foo,"nonexistent"));
var_dump(property_exists($foo,""));
var_dump(property_exists(array(),"test"));
var_dump(property_exists(1,"test"));
var_dump(property_exists(true,"test"));
$foo->bar();
$bar = new bar;
$bar->test();
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for property_exists() in %s on line %d
NULL
Warning: Wrong parameter count for property_exists() in %s on line %d
NULL
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
Warning: First parameter must either be an object or the name of an existing class in %s on line %d
NULL
Warning: First parameter must either be an object or the name of an existing class in %s on line %d
NULL
Warning: First parameter must either be an object or the name of an existing class in %s on line %d
NULL
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
Done

34
Zend/tests/012.phpt Normal file
View File

@ -0,0 +1,34 @@
--TEST--
class_exists() tests
--FILE--
<?php
class foo {
}
var_dump(class_exists());
var_dump(class_exists("qwerty"));
var_dump(class_exists(""));
var_dump(class_exists(array()));
var_dump(class_exists("test", false));
var_dump(class_exists("foo", false));
var_dump(class_exists("foo"));
var_dump(class_exists("stdClass", false));
var_dump(class_exists("stdClass"));
echo "Done\n";
?>
--EXPECTF--
Warning: class_exists() expects at least 1 parameter, 0 given in %s on line %d
NULL
bool(false)
bool(false)
Warning: class_exists() expects parameter 1 to be string, array given in %s on line %d
NULL
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
Done

34
Zend/tests/013.phpt Normal file
View File

@ -0,0 +1,34 @@
--TEST--
interface_exists() tests
--FILE--
<?php
interface foo {
}
var_dump(interface_exists());
var_dump(interface_exists("qwerty"));
var_dump(interface_exists(""));
var_dump(interface_exists(array()));
var_dump(interface_exists("test", false));
var_dump(interface_exists("foo", false));
var_dump(interface_exists("foo"));
var_dump(interface_exists("stdClass", false));
var_dump(interface_exists("stdClass"));
echo "Done\n";
?>
--EXPECTF--
Warning: interface_exists() expects at least 1 parameter, 0 given in %s on line %d
NULL
bool(false)
bool(false)
Warning: interface_exists() expects parameter 1 to be string, array given in %s on line %d
NULL
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)
Done

3
Zend/tests/014.inc Normal file
View File

@ -0,0 +1,3 @@
<?php
/* dummy file for 014.phpt */
?>

52
Zend/tests/014.phpt Normal file
View File

@ -0,0 +1,52 @@
--TEST--
get_included_files() tests
--FILE--
<?php
var_dump(get_included_files());
include(dirname(__FILE__)."/014.inc");
var_dump(get_included_files());
var_dump(get_included_files(1,1));
include_once(dirname(__FILE__)."/014.inc");
var_dump(get_included_files());
var_dump(get_included_files(1));
include(dirname(__FILE__)."/014.inc");
var_dump(get_included_files());
echo "Done\n";
?>
--EXPECTF--
array(1) {
[0]=>
string(%d) "%s"
}
array(2) {
[0]=>
string(%d) "%s"
[1]=>
string(%d) "%s"
}
Warning: Wrong parameter count for get_included_files() in %s on line %d
NULL
array(2) {
[0]=>
string(%d) "%s"
[1]=>
string(%d) "%s"
}
Warning: Wrong parameter count for get_included_files() in %s on line %d
NULL
array(2) {
[0]=>
string(%d) "%s"
[1]=>
string(%d) "%s"
}
Done

35
Zend/tests/015.phpt Normal file
View File

@ -0,0 +1,35 @@
--TEST--
trigger_error() tests
--FILE--
<?php
var_dump(trigger_error());
var_dump(trigger_error("error"));
var_dump(trigger_error(array()));
var_dump(trigger_error("error", -1));
var_dump(trigger_error("error", 0));
var_dump(trigger_error("error", E_USER_WARNING));
echo "Done\n";
?>
--EXPECTF--
Warning: Wrong parameter count for trigger_error() in %s on line %d
NULL
Notice: error in %s on line %d
bool(true)
Notice: Array to string conversion in %s on line %d
Notice: Array in %s on line %d
bool(true)
Warning: Invalid error type specified in %s on line %d
bool(false)
Warning: Invalid error type specified in %s on line %d
bool(false)
Warning: error in %s on line %d
bool(true)
Done