summaryrefslogtreecommitdiff
path: root/tests/reflection
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
commit0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch)
treed5107db4b7369603ac7c753829e8972ee74949f7 /tests/reflection
parentce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff)
downloadphp-upstream/5.1.2.tar.gz
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'tests/reflection')
-rwxr-xr-xtests/reflection/001.phpt89
-rwxr-xr-xtests/reflection/002.phpt63
-rwxr-xr-xtests/reflection/003.phpt31
-rwxr-xr-xtests/reflection/004.phpt42
-rwxr-xr-xtests/reflection/005.phpt54
-rwxr-xr-xtests/reflection/006.phpt103
-rwxr-xr-xtests/reflection/bug30146.phpt23
-rwxr-xr-xtests/reflection/bug30148.phpt35
-rwxr-xr-xtests/reflection/bug30209.phpt31
-rwxr-xr-xtests/reflection/bug31651.phpt24
-rwxr-xr-xtests/reflection/bug33389.phpt97
-rw-r--r--tests/reflection/exception.inc16
-rwxr-xr-xtests/reflection/parameters_001.phpt38
13 files changed, 0 insertions, 646 deletions
diff --git a/tests/reflection/001.phpt b/tests/reflection/001.phpt
deleted file mode 100755
index 6a9d31a30..000000000
--- a/tests/reflection/001.phpt
+++ /dev/null
@@ -1,89 +0,0 @@
---TEST--
-Reflection inheritance
---FILE--
-<?php
-
-class ReflectionClassEx extends ReflectionClass
-{
- public $bla;
-
- function getMethodNames()
- {
- $res = array();
- foreach($this->getMethods() as $m)
- {
- $res[] = $m->class . '::' . $m->name;
- }
- return $res;
- }
-}
-
-$r = new ReflectionClassEx('ReflectionClassEx');
-
-$exp = array (
- 'UMLClass::__clone',
- 'UMLClass::export',
- 'UMLClass::__construct',
- 'UMLClass::__toString',
- 'UMLClass::getName',
- 'UMLClass::isInternal',
- 'UMLClass::isUserDefined',
- 'UMLClass::isInstantiable',
- 'UMLClass::getFileName',
- 'UMLClass::getStartLine',
- 'UMLClass::getEndLine',
- 'UMLClass::getDocComment',
- 'UMLClass::getConstructor',
- 'UMLClass::getMethod',
- 'UMLClass::getMethods',
- 'UMLClass::getProperty',
- 'UMLClass::getProperties',
- 'UMLClass::getConstants',
- 'UMLClass::getConstant',
- 'UMLClass::getInterfaces',
- 'UMLClass::isInterface',
- 'UMLClass::isAbstract',
- 'UMLClass::isFinal',
- 'UMLClass::getModifiers',
- 'UMLClass::isInstance',
- 'UMLClass::newInstance',
- 'UMLClass::getParentClass',
- 'UMLClass::isSubclassOf',
- 'UMLClass::getStaticProperties',
- 'UMLClass::getDefaultProperties',
- 'UMLClass::isIterateable',
- 'UMLClass::implementsInterface',
- 'UMLClass::getExtension',
- 'UMLClass::getExtensionName');
-
-$miss = array();
-
-$res = $r->getMethodNames();
-
-foreach($exp as $m)
-{
- if (!in_array($m, $exp))
- {
- $miss[] = $m;
- }
-}
-
-var_dump($miss);
-
-$props = array_keys(get_class_vars('ReflectionClassEx'));
-sort($props);
-var_dump($props);
-var_dump($r->name);
-?>
-===DONE===
---EXPECT--
-array(0) {
-}
-array(2) {
- [0]=>
- string(3) "bla"
- [1]=>
- string(4) "name"
-}
-string(17) "ReflectionClassEx"
-===DONE===
diff --git a/tests/reflection/002.phpt b/tests/reflection/002.phpt
deleted file mode 100755
index bef4c8166..000000000
--- a/tests/reflection/002.phpt
+++ /dev/null
@@ -1,63 +0,0 @@
---TEST--
-Reflection properties are read only
---FILE--
-<?php
-
-class ReflectionMethodEx extends ReflectionMethod
-{
- public $foo = "xyz";
-
- function __construct($c,$m)
- {
- echo __METHOD__ . "\n";
- parent::__construct($c,$m);
- }
-}
-
-$r = new ReflectionMethodEx('ReflectionMethodEx','getName');
-
-var_dump($r->class);
-var_dump($r->name);
-var_dump($r->foo);
-@var_dump($r->bar);
-
-try
-{
- $r->class = 'bullshit';
-}
-catch(ReflectionException $e)
-{
- echo $e->getMessage() . "\n";
-}
-try
-{
-$r->name = 'bullshit';
-}
-catch(ReflectionException $e)
-{
- echo $e->getMessage() . "\n";
-}
-
-$r->foo = 'bar';
-$r->bar = 'baz';
-
-var_dump($r->class);
-var_dump($r->name);
-var_dump($r->foo);
-var_dump($r->bar);
-
-?>
-===DONE===
---EXPECTF--
-ReflectionMethodEx::__construct
-string(18) "ReflectionMethodEx"
-string(7) "getName"
-string(3) "xyz"
-NULL
-Cannot set read-only property ReflectionMethodEx::$class
-Cannot set read-only property ReflectionMethodEx::$name
-string(18) "ReflectionMethodEx"
-string(7) "getName"
-string(3) "bar"
-string(3) "baz"
-===DONE===
diff --git a/tests/reflection/003.phpt b/tests/reflection/003.phpt
deleted file mode 100755
index 660389255..000000000
--- a/tests/reflection/003.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-invoke() with base class method
---FILE--
-<?php
-
-class Foo
-{
- function Test()
- {
- echo __METHOD__ . "\n";
- }
-}
-
-class Bar extends Foo
-{
- function Test()
- {
- echo __METHOD__ . "\n";
- }
-}
-
-$o = new Bar;
-$r = new ReflectionMethod('Foo','Test');
-
-$r->invoke($o);
-
-?>
-===DONE===
---EXPECT--
-Foo::Test
-===DONE===
diff --git a/tests/reflection/004.phpt b/tests/reflection/004.phpt
deleted file mode 100755
index f8a448e6c..000000000
--- a/tests/reflection/004.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-invoke() with non object or null value
---FILE--
-<?php
-
-class a {
- function a(){
- }
-}
-class b {
-}
-
-$b = new b();
-
-$a=new ReflectionClass("a");
-$m=$a->getMethod("a");
-
-try {
- $m->invoke(null);
-} catch (ReflectionException $E) {
- echo $E->getMessage()."\n";
-}
-
-
-try {
- $m->invoke($b);
-} catch (ReflectionException $E) {
- echo $E->getMessage()."\n";
-}
-
-$b = new a();
-try {
- $m->invoke($b);
-} catch (ReflectionException $E) {
- echo $E->getMessage()."\n";
-}
-
-echo "===DONE===\n";?>
---EXPECT--
-Non-object passed to Invoke()
-Given object is not an instance of the class this method was declared in
-===DONE===
diff --git a/tests/reflection/005.phpt b/tests/reflection/005.phpt
deleted file mode 100755
index f337e44ae..000000000
--- a/tests/reflection/005.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-ReflectionMethod::getDocComment() uses wrong comment block
---FILE--
-<?php
-
-function strip_doc_comment($c)
-{
- if (!strlen($c) || $c === false) return $c;
- return trim(substr($c, 3, -2));
-}
-
-/** Comment for class A */
-class A
-{
- /** Method A::bla()
- */
- function bla()
- {
- }
-
- function foo() {
- /**
- * This is a valid comment inside a method
- */
- }
-
- function bar() {
- // I don't have a doc comment....
- }
-
- /**
- * Comment for A::baz()
- */
- function baz() {
- }
-}
-
-$r = new ReflectionClass('A');
-var_dump(strip_doc_comment($r->getDocComment()));
-
-foreach($r->getMethods() as $m)
-{
- var_dump(strip_doc_comment($m->getDocComment()));
-}
-
-?>
-===DONE===
---EXPECT--
-string(19) "Comment for class A"
-string(15) "Method A::bla()"
-bool(false)
-bool(false)
-string(22) "* Comment for A::baz()"
-===DONE===
diff --git a/tests/reflection/006.phpt b/tests/reflection/006.phpt
deleted file mode 100755
index 89c438765..000000000
--- a/tests/reflection/006.phpt
+++ /dev/null
@@ -1,103 +0,0 @@
---TEST--
-ReflectionClass::[gs]etStaticPropertyValue
---FILE--
-<?php
-
-/* ReflectionClass cannot touch protected or private static properties */
-
-/* ReflectionClass cannot create or delete static properties */
-
-Class Test
-{
- static public $pub = 'pub';
- static protected $pro = 'pro';
- static private $pri = 'pri';
-
- static function testing()
- {
- $ref = new ReflectionClass('Test');
-
- foreach(array('pub', 'pro', 'pri') as $name)
- {
- try
- {
- var_dump($ref->getStaticPropertyValue($name));
- var_dump($ref->getStaticPropertyValue($name));
- $ref->setStaticPropertyValue($name, 'updated');
- var_dump($ref->getStaticPropertyValue($name));
- }
- catch(Exception $e)
- {
- echo "EXCEPTION\n";
- }
- }
- }
-}
-
-Class TestDerived extends Test
-{
-// static public $pub = 'pub';
-// static protected $pro = 'pro';
- static private $pri = 'pri';
-
- static function testing()
- {
- $ref = new ReflectionClass('Test');
-
- foreach(array('pub', 'pro', 'pri') as $name)
- {
- try
- {
- var_dump($ref->getStaticPropertyValue($name));
- var_dump($ref->getStaticPropertyValue($name));
- $ref->setStaticPropertyValue($name, 'updated');
- var_dump($ref->getStaticPropertyValue($name));
- }
- catch(Exception $e)
- {
- echo "EXCEPTION\n";
- }
- }
- }
-}
-
-$ref = new ReflectionClass('Test');
-
-foreach(array('pub', 'pro', 'pri') as $name)
-{
- try
- {
- var_dump($ref->getStaticPropertyValue($name));
- var_dump($ref->getStaticPropertyValue($name));
- $ref->setStaticPropertyValue($name, 'updated');
- var_dump($ref->getStaticPropertyValue($name));
- }
- catch(Exception $e)
- {
- echo "EXCEPTION\n";
- }
-}
-
-Test::testing();
-TestDerived::testing();
-
-?>
-===DONE===
-<?php exit(0); ?>
---EXPECT--
-string(3) "pub"
-string(3) "pub"
-string(7) "updated"
-EXCEPTION
-EXCEPTION
-string(7) "updated"
-string(7) "updated"
-string(7) "updated"
-EXCEPTION
-EXCEPTION
-string(7) "updated"
-string(7) "updated"
-string(7) "updated"
-EXCEPTION
-EXCEPTION
-===DONE===
diff --git a/tests/reflection/bug30146.phpt b/tests/reflection/bug30146.phpt
deleted file mode 100755
index 72c6d2e5f..000000000
--- a/tests/reflection/bug30146.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Bug #30146 (ReflectionProperty->getValue() requires instance for static property)
---FILE--
-<?php
-class test {
- static public $a = 1;
-}
-
-$r = new ReflectionProperty('test', 'a');
-var_dump($r->getValue(null));
-
-$r->setValue(NULL, 2);
-var_dump($r->getValue());
-
-$r->setValue(3);
-var_dump($r->getValue());
-?>
-===DONE===
---EXPECT--
-int(1)
-int(2)
-int(3)
-===DONE=== \ No newline at end of file
diff --git a/tests/reflection/bug30148.phpt b/tests/reflection/bug30148.phpt
deleted file mode 100755
index bc4415bfd..000000000
--- a/tests/reflection/bug30148.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes)
---FILE--
-<?php
-
-class Root
-{
- function Root() {}
-}
-class Base extends Root
-{
- function __construct() {}
-}
-class Derived extends Base
-{
-}
-$a = new ReflectionMethod('Root','Root');
-$b = new ReflectionMethod('Base','Root');
-$c = new ReflectionMethod('Base','__construct');
-$d = new ReflectionMethod('Derived','Root');
-$e = new ReflectionMethod('Derived','__construct');
-var_dump($a->isConstructor());
-var_dump($b->isConstructor());
-var_dump($c->isConstructor());
-var_dump($d->isConstructor());
-var_dump($e->isConstructor());
-?>
-===DONE===
---EXPECT--
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-===DONE=== \ No newline at end of file
diff --git a/tests/reflection/bug30209.phpt b/tests/reflection/bug30209.phpt
deleted file mode 100755
index 6705c6704..000000000
--- a/tests/reflection/bug30209.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Bug #30209 (ReflectionClass::getMethod() lowercases attribute)
---FILE--
-<?php
-
-class Foo
-{
- private $name = 'testBAR';
-
- public function testBAR()
- {
- try
- {
- $class = new ReflectionClass($this);
- var_dump($this->name);
- $method = $class->getMethod($this->name);
- var_dump($this->name);
- }
-
- catch (Exception $e) {}
- }
-}
-
-$foo = new Foo;
-$foo->testBAR();
-?>
-===DONE===
---EXPECTF--
-string(7) "testBAR"
-string(7) "testBAR"
-===DONE===
diff --git a/tests/reflection/bug31651.phpt b/tests/reflection/bug31651.phpt
deleted file mode 100755
index 60bee14e9..000000000
--- a/tests/reflection/bug31651.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays.)
---FILE--
-<?php
-
-class Test
-{
- public $a = array('a' => 1);
-}
-
-$ref = new ReflectionClass('Test');
-
-print_r($ref->getDefaultProperties());
-
-?>
---EXPECT--
-Array
-(
- [a] => Array
- (
- [a] => 1
- )
-
-)
diff --git a/tests/reflection/bug33389.phpt b/tests/reflection/bug33389.phpt
deleted file mode 100755
index 36f7079e2..000000000
--- a/tests/reflection/bug33389.phpt
+++ /dev/null
@@ -1,97 +0,0 @@
---TEST--
-Bug #33389 (double free() when exporting a ReflectionClass)
---FILE--
-<?php
-define ('foobar', 1);
-class Test {
- function foo1($arg=foobar) {
- }
- function foo2($arg=null) {
- }
- function foo3($arg=false) {
- }
- function foo4($arg='foo') {
- }
- function foo5($arg=1) {
- }
- function bar($arg) {
- }
- function foo() {
- }
-}
-Reflection::export(new ReflectionClass('Test'));
-?>
-===DONE===
-<?php exit(0); ?>
---EXPECTF--
-Class [ <user> class Test ] {
- @@ %sbug33389.php 3-18
-
- - Constants [0] {
- }
-
- - Static properties [0] {
- }
-
- - Static methods [0] {
- }
-
- - Properties [0] {
- }
-
- - Methods [7] {
- Method [ <user> public method foo1 ] {
- @@ %sbug33389.php 4 - 5
-
- - Parameters [1] {
- Parameter #0 [ <optional> $arg = 1 ]
- }
- }
-
- Method [ <user> public method foo2 ] {
- @@ %sbug33389.php 6 - 7
-
- - Parameters [1] {
- Parameter #0 [ <optional> $arg = NULL ]
- }
- }
-
- Method [ <user> public method foo3 ] {
- @@ %sbug33389.php 8 - 9
-
- - Parameters [1] {
- Parameter #0 [ <optional> $arg = false ]
- }
- }
-
- Method [ <user> public method foo4 ] {
- @@ %sbug33389.php 10 - 11
-
- - Parameters [1] {
- Parameter #0 [ <optional> $arg = 'foo' ]
- }
- }
-
- Method [ <user> public method foo5 ] {
- @@ %sbug33389.php 12 - 13
-
- - Parameters [1] {
- Parameter #0 [ <optional> $arg = 1 ]
- }
- }
-
- Method [ <user> public method bar ] {
- @@ %sbug33389.php 14 - 15
-
- - Parameters [1] {
- Parameter #0 [ <required> $arg ]
- }
- }
-
- Method [ <user> public method foo ] {
- @@ %sbug33389.php 16 - 17
- }
- }
-}
-
-===DONE===
diff --git a/tests/reflection/exception.inc b/tests/reflection/exception.inc
deleted file mode 100644
index e40333996..000000000
--- a/tests/reflection/exception.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-class ReflectionExceptionEx extends ReflectionException {
- function MyException($_errno, $_errmsg) {
- $this->errno = $_errno;
- $this->errmsg = $_errmsg;
- }
-
- function getErrno() {
- return $this->errno;
- }
-
- function getErrmsg() {
- return $this->errmsg;
- }
-}
-?>
diff --git a/tests/reflection/parameters_001.phpt b/tests/reflection/parameters_001.phpt
deleted file mode 100755
index 0879756ea..000000000
--- a/tests/reflection/parameters_001.phpt
+++ /dev/null
@@ -1,38 +0,0 @@
---TEST--
-Check for parameter being optional
---FILE--
-<?php
-
-class Test {
- function func($x, $y = NULL){
- }
-}
-
-
-$f = new ReflectionMethod('Test', 'func');
-var_dump($f->getNumberOfParameters());
-var_dump($f->getNumberOfRequiredParameters());
-
-$p = new ReflectionParameter(array('Test', 'func'), 'x');
-var_dump($p->isOptional());
-
-$p = new ReflectionParameter(array('Test', 'func'), 'y');
-var_dump($p->isOptional());
-
-try {
- $p = new ReflectionParameter(array('Test', 'func'), 'z');
- var_dump($p->isOptional());
-}
-catch (Exception $e) {
- var_dump($e->getMessage());
-}
-
-?>
-===DONE===
---EXPECT--
-int(2)
-int(1)
-bool(false)
-bool(true)
-string(54) "The parameter specified by its name could not be found"
-===DONE===