summaryrefslogtreecommitdiff
path: root/ext/reflection/tests
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2008-12-03 20:30:45 +0000
committerSVN Migration <svn@php.net>2008-12-03 20:30:45 +0000
commit2876046398950e59c3b3c460e67e6fec7ff2ba3c (patch)
tree33b2b8b4b859960a6446ad19d0ada1c55f9cfcda /ext/reflection/tests
parent3fb86b0b9e79e6a3312b694f30ee627e2e1b325c (diff)
downloadphp-git-php-5.3.0alpha2.tar.gz
This commit was manufactured by cvs2svn to create tag 'php_5_3_0alpha2'.php-5.3.0alpha2
Diffstat (limited to 'ext/reflection/tests')
-rw-r--r--ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt10
-rw-r--r--ext/reflection/tests/reflectionClass_getNamespaceName.phpt10
-rw-r--r--ext/reflection/tests/reflectionProperty_setAccessible.phpt90
3 files changed, 36 insertions, 74 deletions
diff --git a/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt b/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt
index 08b3dddabd..cd1f52c2ab 100644
--- a/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt
+++ b/ext/reflection/tests/ReflectionFunction_getNamespaceName.phpt
@@ -2,16 +2,16 @@
ReflectionFunction::getNamespaceName()
--FILE--
<?php
-namespace A\B;
+namespace A::B;
function foo() {}
-$function = new \ReflectionFunction('sort');
+$function = new ReflectionFunction('sort');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
-$function = new \ReflectionFunction('A\\B\\foo');
+$function = new ReflectionFunction('A::B::foo');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
@@ -23,7 +23,7 @@ string(4) "sort"
string(0) ""
string(4) "sort"
bool(true)
-string(7) "A\B\foo"
-string(3) "A\B"
+string(9) "A::B::foo"
+string(4) "A::B"
string(3) "foo"
diff --git a/ext/reflection/tests/reflectionClass_getNamespaceName.phpt b/ext/reflection/tests/reflectionClass_getNamespaceName.phpt
index 1c46e0656b..4b511908fe 100644
--- a/ext/reflection/tests/reflectionClass_getNamespaceName.phpt
+++ b/ext/reflection/tests/reflectionClass_getNamespaceName.phpt
@@ -2,17 +2,17 @@
ReflectionClass::getNamespaceName()
--FILE--
<?php
-namespace A\B;
+namespace A::B;
class Foo {
}
-$function = new \ReflectionClass('stdClass');
+$function = new ReflectionClass('stdClass');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
-$function = new \ReflectionClass('A\\B\\Foo');
+$function = new ReflectionClass('A::B::Foo');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
@@ -24,7 +24,7 @@ string(8) "stdClass"
string(0) ""
string(8) "stdClass"
bool(true)
-string(7) "A\B\Foo"
-string(3) "A\B"
+string(9) "A::B::Foo"
+string(4) "A::B"
string(3) "Foo"
diff --git a/ext/reflection/tests/reflectionProperty_setAccessible.phpt b/ext/reflection/tests/reflectionProperty_setAccessible.phpt
index 927a8a8613..c48a828e6b 100644
--- a/ext/reflection/tests/reflectionProperty_setAccessible.phpt
+++ b/ext/reflection/tests/reflectionProperty_setAccessible.phpt
@@ -2,81 +2,43 @@
Test ReflectionProperty::setAccessible().
--FILE--
<?php
-class A {
- protected $protected = 'a';
- protected static $protectedStatic = 'b';
- private $private = 'c';
- private static $privateStatic = 'd';
-}
-
-$a = new A;
-$protected = new ReflectionProperty($a, 'protected');
-$protectedStatic = new ReflectionProperty('A', 'protectedStatic');
-$private = new ReflectionProperty($a, 'private');
-$privateStatic = new ReflectionProperty('A', 'privateStatic');
-
-try {
- var_dump($protected->getValue($a));
-}
-catch (ReflectionException $e) {
- var_dump($e->getMessage());
+class TestClass {
+ public $pub;
+ public $pub2 = 5;
+ static public $stat = "static property";
+ protected $prot = 4;
+ private $priv = "keepOut";
}
-try {
- var_dump($protectedStatic->getValue());
+class AnotherClass {
}
-catch (ReflectionException $e) {
- var_dump($e->getMessage());
-}
+$instance = new TestClass();
+echo "\nProtected property:\n";
+$propInfo = new ReflectionProperty('TestClass', 'prot');
try {
- var_dump($private->getValue($a));
+ var_dump($propInfo->getValue($instance));
}
-
-catch (ReflectionException $e) {
- var_dump($e->getMessage());
+catch(Exception $exc) {
+ echo $exc->getMessage(), "\n";
}
+$propInfo->setAccessible(true);
+var_dump($propInfo->getValue($instance));
+
+$propInfo->setAccessible(false);
try {
- var_dump($privateStatic->getValue());
+ var_dump($propInfo->getValue($instance));
}
-
-catch (ReflectionException $e) {
- var_dump($e->getMessage());
+catch(Exception $exc) {
+ echo $exc->getMessage(), "\n";
}
-
-$protected->setAccessible(TRUE);
-$protectedStatic->setAccessible(TRUE);
-$private->setAccessible(TRUE);
-$privateStatic->setAccessible(TRUE);
-
-var_dump($protected->getValue($a));
-var_dump($protectedStatic->getValue());
-var_dump($private->getValue($a));
-var_dump($privateStatic->getValue());
-
-$protected->setValue($a, 'e');
-$protectedStatic->setValue('f');
-$private->setValue($a, 'g');
-$privateStatic->setValue('h');
-
-var_dump($protected->getValue($a));
-var_dump($protectedStatic->getValue());
-var_dump($private->getValue($a));
-var_dump($privateStatic->getValue());
?>
---EXPECT--
-string(44) "Cannot access non-public member A::protected"
-string(50) "Cannot access non-public member A::protectedStatic"
-string(42) "Cannot access non-public member A::private"
-string(48) "Cannot access non-public member A::privateStatic"
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-string(1) "e"
-string(1) "f"
-string(1) "g"
-string(1) "h"
+--EXPECTF--
+
+Protected property:
+Cannot access non-public member TestClass::prot
+int(4)
+Cannot access non-public member TestClass::prot