mirror of
https://github.com/php/php-src.git
synced 2026-04-25 17:08:14 +02:00
Testfest: various tests for ReflectionParameter
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
ReflectionParameter::export()
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
foreach($reflect->getParameters() as $key => $value) {
|
||||
echo ReflectionParameter::export('ReflectionParameterTest', $key);
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
Parameter #0 [ <required> $test ]
|
||||
Parameter #1 [ <optional> $test2 = NULL ]
|
||||
==DONE==
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
ReflectionParameter::export() without parameters
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
foreach($reflect->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==
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
ReflectionParameter::export() with incorrect first parameter
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
$params = $reflect->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
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
ReflectionParameter::export() with incorrect second parameter
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
$params = $reflect->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
|
||||
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
ReflectionParameter::getDeclaringFunction()
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
#testfest roosendaal on 2008-05-10
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
$params = $reflect->getParameters();
|
||||
foreach($params as $key => $value) {
|
||||
echo $value->getDeclaringFunction() . "\n";
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
Function [ <user> function ReflectionParameterTest ] {
|
||||
@@ %s.php %d - %d
|
||||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $test ]
|
||||
Parameter #1 [ <optional> $test2 = NULL ]
|
||||
}
|
||||
}
|
||||
|
||||
Function [ <user> function ReflectionParameterTest ] {
|
||||
@@ %s.php %d - %d
|
||||
|
||||
- Parameters [2] {
|
||||
Parameter #0 [ <required> $test ]
|
||||
Parameter #1 [ <optional> $test2 = NULL ]
|
||||
}
|
||||
}
|
||||
|
||||
==DONE==
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
ReflectionParameter::getPosition()
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
#testfest roosendaal on 2008-05-10
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
$params = $reflect->getParameters();
|
||||
foreach($params as $key => $value) {
|
||||
var_dump($value->getPosition());
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(1)
|
||||
==DONE==
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
ReflectionParameter::__toString()
|
||||
--CREDITS--
|
||||
Stefan Koopmanschap <stefan@stefankoopmanschap.nl>
|
||||
--FILE--
|
||||
<?php
|
||||
function ReflectionParameterTest($test, $test2 = null) {
|
||||
echo $test;
|
||||
}
|
||||
$reflect = new ReflectionFunction('ReflectionParameterTest');
|
||||
$params = $reflect->getParameters();
|
||||
foreach($params as $key => $value) {
|
||||
echo $value->__toString() . "\n";
|
||||
}
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
Parameter #0 [ <required> $test ]
|
||||
Parameter #1 [ <optional> $test2 = NULL ]
|
||||
==DONE==
|
||||
Reference in New Issue
Block a user