diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
| commit | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch) | |
| tree | 41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/reflection/tests | |
| parent | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff) | |
| download | php-upstream/5.2.2.tar.gz | |
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/reflection/tests')
| -rwxr-xr-x | ext/reflection/tests/008.phpt | 2 | ||||
| -rwxr-xr-x | ext/reflection/tests/009.phpt | 114 | ||||
| -rw-r--r-- | ext/reflection/tests/bug29986.phpt | 2 | ||||
| -rwxr-xr-x | ext/reflection/tests/bug37816.phpt | 2 | ||||
| -rw-r--r-- | ext/reflection/tests/bug38217.phpt | 4 | ||||
| -rw-r--r-- | ext/reflection/tests/bug38653.phpt | 2 | ||||
| -rwxr-xr-x | ext/reflection/tests/bug38942.phpt | 2 | ||||
| -rw-r--r-- | ext/reflection/tests/bug39001.phpt | 2 | ||||
| -rw-r--r-- | ext/reflection/tests/bug39067.phpt | 2 | ||||
| -rw-r--r-- | ext/reflection/tests/bug39884.phpt | 24 | ||||
| -rw-r--r-- | ext/reflection/tests/bug40431.phpt | 140 | ||||
| -rw-r--r-- | ext/reflection/tests/bug40794.phpt | 38 | ||||
| -rwxr-xr-x | ext/reflection/tests/bug41061.phpt | 30 |
13 files changed, 363 insertions, 1 deletions
diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt index 2abdcdb57..c5ee5b33e 100755 --- a/ext/reflection/tests/008.phpt +++ b/ext/reflection/tests/008.phpt @@ -1,5 +1,7 @@ --TEST-- ReflectionMethod::__construct() tests +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt new file mode 100755 index 000000000..bfe37c52f --- /dev/null +++ b/ext/reflection/tests/009.phpt @@ -0,0 +1,114 @@ +--TEST-- +ReflectionFunction basic tests +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +/** +hoho +*/ +function test ($a, $b = 1, $c = "") { + static $var = 1; +} + +$func = new ReflectionFunction("test"); + +var_dump($func->export("test")); +echo "--getName--\n"; +var_dump($func->getName()); +echo "--isInternal--\n"; +var_dump($func->isInternal()); +echo "--isUserDefined--\n"; +var_dump($func->isUserDefined()); +echo "--getFilename--\n"; +var_dump($func->getFilename()); +echo "--getStartline--\n"; +var_dump($func->getStartline()); +echo "--getEndline--\n"; +var_dump($func->getEndline()); +echo "--getDocComment--\n"; +var_dump($func->getDocComment()); +echo "--getStaticVariables--\n"; +var_dump($func->getStaticVariables()); +echo "--invoke--\n"; +var_dump($func->invoke(array(1,2,3))); +echo "--invokeArgs--\n"; +var_dump($func->invokeArgs(array(1,2,3))); +echo "--returnsReference--\n"; +var_dump($func->returnsReference()); +echo "--getParameters--\n"; +var_dump($func->getParameters()); +echo "--getNumberOfParameters--\n"; +var_dump($func->getNumberOfParameters()); +echo "--getNumberOfRequiredParameters--\n"; +var_dump($func->getNumberOfRequiredParameters()); + +echo "Done\n"; + +?> +--EXPECTF-- +/** +hoho +*/ +Function [ <user> function test ] { + @@ %s009.php 6 - 8 + + - Parameters [3] { + Parameter #0 [ <required> $a ] + Parameter #1 [ <optional> $b = 1 ] + Parameter #2 [ <optional> $c = '' ] + } +} + +NULL +--getName-- +string(4) "test" +--isInternal-- +bool(false) +--isUserDefined-- +bool(true) +--getFilename-- +string(%d) "%s009.php" +--getStartline-- +int(6) +--getEndline-- +int(8) +--getDocComment-- +string(11) "/** +hoho +*/" +--getStaticVariables-- +array(1) { + ["var"]=> + int(1) +} +--invoke-- +NULL +--invokeArgs-- +NULL +--returnsReference-- +bool(false) +--getParameters-- +array(3) { + [0]=> + &object(ReflectionParameter)#2 (1) { + ["name"]=> + string(1) "a" + } + [1]=> + &object(ReflectionParameter)#3 (1) { + ["name"]=> + string(1) "b" + } + [2]=> + &object(ReflectionParameter)#4 (1) { + ["name"]=> + string(1) "c" + } +} +--getNumberOfParameters-- +int(3) +--getNumberOfRequiredParameters-- +int(1) +Done diff --git a/ext/reflection/tests/bug29986.phpt b/ext/reflection/tests/bug29986.phpt index 997bcf7cc..062eff6f9 100644 --- a/ext/reflection/tests/bug29986.phpt +++ b/ext/reflection/tests/bug29986.phpt @@ -1,5 +1,7 @@ --TEST-- Reflection Bug #29986 (Class constants won't work with predefined constants when using ReflectionClass) +--INI-- +precision=14 --SKIPIF-- <?php extension_loaded('reflection') or die('skip'); ?> --FILE-- diff --git a/ext/reflection/tests/bug37816.phpt b/ext/reflection/tests/bug37816.phpt index 18a49046d..1121d5418 100755 --- a/ext/reflection/tests/bug37816.phpt +++ b/ext/reflection/tests/bug37816.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #37816 (ReflectionProperty does not throw exception when accessing protected attribute) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt index 55e0c4664..590d7f79e 100644 --- a/ext/reflection/tests/bug38217.phpt +++ b/ext/reflection/tests/bug38217.phpt @@ -1,5 +1,7 @@ --TEST-- -#38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory) +Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt index 68781d2ab..0e6fcd035 100644 --- a/ext/reflection/tests/bug38653.phpt +++ b/ext/reflection/tests/bug38653.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #38653 (memory leak in ReflectionClass::getConstant()) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt index f66f2552b..a1ba05ba0 100755 --- a/ext/reflection/tests/bug38942.phpt +++ b/ext/reflection/tests/bug38942.phpt @@ -1,5 +1,7 @@ --TEST--
Bug #38942 (Double old-style-ctor inheritance)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class foo {
diff --git a/ext/reflection/tests/bug39001.phpt b/ext/reflection/tests/bug39001.phpt index 1ed675f02..59bab0291 100644 --- a/ext/reflection/tests/bug39001.phpt +++ b/ext/reflection/tests/bug39001.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #39001 (ReflectionProperty returns incorrect declaring class for protected properties) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt index 8a7a6044e..020ae74e4 100644 --- a/ext/reflection/tests/bug39067.phpt +++ b/ext/reflection/tests/bug39067.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #39067 (getDeclaringClass() and private properties) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug39884.phpt b/ext/reflection/tests/bug39884.phpt new file mode 100644 index 000000000..8022954bf --- /dev/null +++ b/ext/reflection/tests/bug39884.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #39884 (ReflectionParameter::getClass() throws exception for type hint self) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php +class stubParamTest +{ + function paramTest(self $param) + { + // nothing to do + } +} +$test1 = new stubParamTest(); +$test2 = new stubParamTest(); +$test1->paramTest($test2); +$refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param'); +var_dump($refParam->getClass()); +?> +--EXPECT-- +object(ReflectionClass)#4 (1) { + ["name"]=> + string(13) "stubParamTest" +} diff --git a/ext/reflection/tests/bug40431.phpt b/ext/reflection/tests/bug40431.phpt new file mode 100644 index 000000000..2f2b2d932 --- /dev/null +++ b/ext/reflection/tests/bug40431.phpt @@ -0,0 +1,140 @@ +--TEST-- +Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +echo "=== 1st test ===\n"; + +$Obj->value = 'value'; +$RefObj = new ReflectionObject($Obj); + +$props = $RefObj->getProperties(); + +var_dump($props); +var_dump($props[0]->isStatic()); +var_dump($props[0]->isPrivate()); +var_dump($props[0]->isPublic()); +var_dump($props[0]->isProtected()); + +echo "=== 2nd test ===\n"; + +class test1 { +} + +class test2 extends test1{ +} + +$Obj = new test2; +$Obj->value = 'value'; +$RefObj = new ReflectionObject($Obj); + +$props = $RefObj->getProperties(); + +var_dump($props); +var_dump($props[0]->isStatic()); +var_dump($props[0]->isPrivate()); +var_dump($props[0]->isPublic()); +var_dump($props[0]->isProtected()); + +echo "=== 3rd test ===\n"; + +class test3 { +} + +$Obj = new test3; +$Obj->value = 'value'; +$RefObj = new ReflectionObject($Obj); + +$props = $RefObj->getProperties(); + +var_dump($props); +var_dump($props[0]->isStatic()); +var_dump($props[0]->isPrivate()); +var_dump($props[0]->isPublic()); +var_dump($props[0]->isProtected()); + +echo "=== 4th test ===\n"; + +class test5 { + private $value = 1; +} + +class test4 extends test5{ +} + +$Obj = new test4; +$Obj->value = 'value'; +$RefObj = new ReflectionObject($Obj); + +$props = $RefObj->getProperties(); + +var_dump($props); +var_dump($props[0]->isStatic()); +var_dump($props[0]->isPrivate()); +var_dump($props[0]->isPublic()); +var_dump($props[0]->isProtected()); + +echo "Done\n"; +?> +--EXPECTF-- +=== 1st test === + +Strict Standards: Creating default object from empty value in %s on line %d +array(1) { + [0]=> + &object(ReflectionProperty)#%d (2) { + ["name"]=> + string(5) "value" + ["class"]=> + string(8) "stdClass" + } +} +bool(false) +bool(false) +bool(true) +bool(false) +=== 2nd test === +array(1) { + [0]=> + &object(ReflectionProperty)#%d (2) { + ["name"]=> + string(5) "value" + ["class"]=> + string(5) "test2" + } +} +bool(false) +bool(false) +bool(true) +bool(false) +=== 3rd test === +array(1) { + [0]=> + &object(ReflectionProperty)#%d (2) { + ["name"]=> + string(5) "value" + ["class"]=> + string(5) "test3" + } +} +bool(false) +bool(false) +bool(true) +bool(false) +=== 4th test === +array(1) { + [0]=> + &object(ReflectionProperty)#%d (2) { + ["name"]=> + string(5) "value" + ["class"]=> + string(5) "test4" + } +} +bool(false) +bool(false) +bool(true) +bool(false) +Done diff --git a/ext/reflection/tests/bug40794.phpt b/ext/reflection/tests/bug40794.phpt new file mode 100644 index 000000000..ca4f3e92b --- /dev/null +++ b/ext/reflection/tests/bug40794.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #40794 (ReflectionObject::getValues() may crash when used with dynamic properties) +--SKIPIF-- +<?php +if (!extension_loaded("reflection")) { + die("skip"); +} +?> +--FILE-- +<?php + +$obj = new stdClass(); +$obj->prop1 = '1'; +$obj->prop2 = '2'; +$obj->prop3 = '3'; + +$reflect = new ReflectionObject($obj); + +$array = array(); +foreach($reflect->getProperties() as $prop) +{ + $array[$prop->getName()] = $prop->getValue($obj); +} + +var_dump($array); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + ["prop1"]=> + string(1) "1" + ["prop2"]=> + string(1) "2" + ["prop3"]=> + string(1) "3" +} +Done diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt new file mode 100755 index 000000000..977828ef6 --- /dev/null +++ b/ext/reflection/tests/bug41061.phpt @@ -0,0 +1,30 @@ +--TEST-- +Reflection Bug #41061 ("visibility error" in ReflectionFunction::export()) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function foo() { +} + +class bar { + private function foo() { + } +} + +Reflection::export(new ReflectionFunction('foo')); +Reflection::export(new ReflectionMethod('bar', 'foo')); +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Function [ <user> function foo ] { + @@ %sbug41061.php 3 - 4 +} + +Method [ <user> private method foo ] { + @@ %sbug41061.php 7 - 8 +} + +===DONE=== |
