From 99ffc8701aee204df8a993acf76c2cc79499043d Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Thu, 12 Jun 2008 21:41:09 +0000 Subject: [PATCH] Testfest: various tests for ReflectionParameter --- .../reflectionParameter_export_basic.phpt | 19 ++++++++++ .../reflectionParameter_export_error.phpt | 21 +++++++++++ .../reflectionParameter_export_error2.phpt | 23 ++++++++++++ .../reflectionParameter_export_error3.phpt | 22 +++++++++++ ...nParameter_getDeclaringFunction_basic.phpt | 37 +++++++++++++++++++ ...reflectionParameter_getPosition_basic.phpt | 21 +++++++++++ .../reflectionParameter_toString_basic.phpt | 20 ++++++++++ 7 files changed, 163 insertions(+) create mode 100644 ext/reflection/tests/reflectionParameter_export_basic.phpt create mode 100644 ext/reflection/tests/reflectionParameter_export_error.phpt create mode 100644 ext/reflection/tests/reflectionParameter_export_error2.phpt create mode 100644 ext/reflection/tests/reflectionParameter_export_error3.phpt create mode 100644 ext/reflection/tests/reflectionParameter_getDeclaringFunction_basic.phpt create mode 100644 ext/reflection/tests/reflectionParameter_getPosition_basic.phpt create mode 100644 ext/reflection/tests/reflectionParameter_toString_basic.phpt diff --git a/ext/reflection/tests/reflectionParameter_export_basic.phpt b/ext/reflection/tests/reflectionParameter_export_basic.phpt new file mode 100644 index 0000000000..74428ccd23 --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_export_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +ReflectionParameter::export() +--CREDITS-- +Stefan Koopmanschap +--FILE-- +getParameters() as $key => $value) { + echo ReflectionParameter::export('ReflectionParameterTest', $key); +} +?> +==DONE== +--EXPECT-- +Parameter #0 [ $test ] +Parameter #1 [ $test2 = NULL ] +==DONE== diff --git a/ext/reflection/tests/reflectionParameter_export_error.phpt b/ext/reflection/tests/reflectionParameter_export_error.phpt new file mode 100644 index 0000000000..31acfe12ae --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_export_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +ReflectionParameter::export() without parameters +--CREDITS-- +Stefan Koopmanschap +--FILE-- +getParameters() as $key => $value) { + ReflectionParameter::export(); +} +?> +==DONE== +--EXPECTF-- + +Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d + +Warning: ReflectionParameter::export() expects at least 2 parameters, 0 given in %s.php on line %d +==DONE== diff --git a/ext/reflection/tests/reflectionParameter_export_error2.phpt b/ext/reflection/tests/reflectionParameter_export_error2.phpt new file mode 100644 index 0000000000..50baff5c59 --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_export_error2.phpt @@ -0,0 +1,23 @@ +--TEST-- +ReflectionParameter::export() with incorrect first parameter +--CREDITS-- +Stefan Koopmanschap +--FILE-- +getParameters(); +foreach($params as $key => $value) { + ReflectionParameter::export($reflect, $key); +} +?> +--EXPECTF-- + +Fatal error: Uncaught exception 'ReflectionException' with message 'The parameter class is expected to be either a string or an array(class, method)' in %s.php:%d +Stack trace: +#0 [internal function]: ReflectionParameter->__construct(Object(ReflectionFunction), 0) +#1 %s.php(%d): ReflectionParameter::export(Object(ReflectionFunction), 0) +#2 {main} + thrown in %s.php on line %d diff --git a/ext/reflection/tests/reflectionParameter_export_error3.phpt b/ext/reflection/tests/reflectionParameter_export_error3.phpt new file mode 100644 index 0000000000..2937853288 --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_export_error3.phpt @@ -0,0 +1,22 @@ +--TEST-- +ReflectionParameter::export() with incorrect second parameter +--CREDITS-- +Stefan Koopmanschap +--FILE-- +getParameters(); +foreach($params as $key => $value) { + ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); +} +--EXPECTF-- + +Fatal error: Uncaught exception 'ReflectionException' with message 'The parameter specified by its name could not be found' in %s.php:%d +Stack trace: +#0 [internal function]: ReflectionParameter->__construct('ReflectionParam...', 'incorrect_param...') +#1 %s.php(%d): ReflectionParameter::export('ReflectionParam...', 'incorrect_param...') +#2 {main} + thrown in %s.php on line %d diff --git a/ext/reflection/tests/reflectionParameter_getDeclaringFunction_basic.phpt b/ext/reflection/tests/reflectionParameter_getDeclaringFunction_basic.phpt new file mode 100644 index 0000000000..59e15a7054 --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_getDeclaringFunction_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +ReflectionParameter::getDeclaringFunction() +--CREDITS-- +Stefan Koopmanschap +#testfest roosendaal on 2008-05-10 +--FILE-- +getParameters(); +foreach($params as $key => $value) { + echo $value->getDeclaringFunction() . "\n"; +} +?> +==DONE== +--EXPECTF-- +Function [ function ReflectionParameterTest ] { + @@ %s.php %d - %d + + - Parameters [2] { + Parameter #0 [ $test ] + Parameter #1 [ $test2 = NULL ] + } +} + +Function [ function ReflectionParameterTest ] { + @@ %s.php %d - %d + + - Parameters [2] { + Parameter #0 [ $test ] + Parameter #1 [ $test2 = NULL ] + } +} + +==DONE== diff --git a/ext/reflection/tests/reflectionParameter_getPosition_basic.phpt b/ext/reflection/tests/reflectionParameter_getPosition_basic.phpt new file mode 100644 index 0000000000..2807bdf66d --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_getPosition_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +ReflectionParameter::getPosition() +--CREDITS-- +Stefan Koopmanschap +#testfest roosendaal on 2008-05-10 +--FILE-- +getParameters(); +foreach($params as $key => $value) { + var_dump($value->getPosition()); +} +?> +==DONE== +--EXPECT-- +int(0) +int(1) +==DONE== diff --git a/ext/reflection/tests/reflectionParameter_toString_basic.phpt b/ext/reflection/tests/reflectionParameter_toString_basic.phpt new file mode 100644 index 0000000000..268ced15ec --- /dev/null +++ b/ext/reflection/tests/reflectionParameter_toString_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +ReflectionParameter::__toString() +--CREDITS-- +Stefan Koopmanschap +--FILE-- +getParameters(); +foreach($params as $key => $value) { + echo $value->__toString() . "\n"; +} +?> +==DONE== +--EXPECT-- +Parameter #0 [ $test ] +Parameter #1 [ $test2 = NULL ] +==DONE== -- 2.50.1