From: Zoe Slattery Date: Thu, 12 Jul 2007 21:08:02 +0000 (+0000) Subject: reflectionObject tests X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a8e9f9b506195e21e904fd97c579638b6d9e825;p=php reflectionObject tests --- diff --git a/ext/reflection/tests/reflectionObject_FileInfo_basic.phpt b/ext/reflection/tests/reflectionObject_FileInfo_basic.phpt new file mode 100644 index 0000000000..d137ed5aaa --- /dev/null +++ b/ext/reflection/tests/reflectionObject_FileInfo_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() - basic function +--FILE-- +getFileName()); +var_dump($rc->getStartLine()); +var_dump($rc->getEndLine()); + +$rc = new ReflectionObject(new stdclass); +var_dump($rc->getFileName()); +var_dump($rc->getStartLine()); +var_dump($rc->getEndLine()); + +Class C { + +} +?> +--EXPECTF-- +string(%d) "%sreflectionObject_FileInfo_basic.php" +int(12) +int(14) +bool(false) +bool(false) +bool(false) +--UEXPECTF-- +unicode(%d) "%sreflectionObject_FileInfo_basic.php" +int(12) +int(14) +bool(false) +bool(false) +bool(false) diff --git a/ext/reflection/tests/reflectionObject_FileInfo_error.phpt b/ext/reflection/tests/reflectionObject_FileInfo_error.phpt new file mode 100644 index 0000000000..299a42e157 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_FileInfo_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams +--FILE-- +$method()); + var_dump($rc->$method(null)); + var_dump($rc->$method('X', 0)); +} +?> +--EXPECTF-- +string(%d) "%s" + +Warning: Wrong parameter count for ReflectionClass::getFileName() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getFileName() in %s on line 10 +NULL +int(2) + +Warning: Wrong parameter count for ReflectionClass::getStartLine() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getStartLine() in %s on line 10 +NULL +int(2) + +Warning: Wrong parameter count for ReflectionClass::getEndLine() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getEndLine() in %s on line 10 +NULL +--UEXPECTF-- +unicode(%d) "%s" + +Warning: Wrong parameter count for ReflectionClass::getFileName() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getFileName() in %s on line 10 +NULL +int(2) + +Warning: Wrong parameter count for ReflectionClass::getStartLine() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getStartLine() in %s on line 10 +NULL +int(2) + +Warning: Wrong parameter count for ReflectionClass::getEndLine() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getEndLine() in %s on line 10 +NULL diff --git a/ext/reflection/tests/reflectionObject_constructor_basic.phpt b/ext/reflection/tests/reflectionObject_constructor_basic.phpt new file mode 100644 index 0000000000..60f6b78f23 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_constructor_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +ReflectionObject::__construct - basic function test +--FILE-- + +--EXPECTF-- +object(ReflectionObject)#%d (1) { + ["name"]=> + string(8) "stdClass" +} +object(ReflectionObject)#%d (1) { + ["name"]=> + string(1) "C" +} +object(ReflectionObject)#%d (1) { + ["name"]=> + string(16) "ReflectionObject" +} +--UEXPECTF-- +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(8) "stdClass" +} +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(1) "C" +} +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(16) "ReflectionObject" +} diff --git a/ext/reflection/tests/reflectionObject_constructor_error.phpt b/ext/reflection/tests/reflectionObject_constructor_error.phpt new file mode 100644 index 0000000000..892aa82dc3 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_constructor_error.phpt @@ -0,0 +1,85 @@ +--TEST-- +ReflectionObject::__construct - invalid arguments +--FILE-- + +--EXPECTF-- +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 3 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, string given in %s on line 4 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} + +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, integer given in %s on line 7 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9 +object(ReflectionObject)#%d (1) { + ["name"]=> + string(0) "" +} +--UEXPECTF-- +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 3 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, Unicode string given in %s on line 4 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} + +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 2 given in %s on line 6 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, integer given in %s on line 7 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given in %s on line 8 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} + +Warning: ReflectionObject::__construct() expects parameter 1 to be object, array given in %s on line 9 +object(ReflectionObject)#%d (1) { + [u"name"]=> + unicode(0) "" +} diff --git a/ext/reflection/tests/reflectionObject_getConstant_basic.phpt b/ext/reflection/tests/reflectionObject_getConstant_basic.phpt new file mode 100644 index 0000000000..151859983d --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstant_basic.phpt @@ -0,0 +1,57 @@ +--TEST-- +ReflectionObject::getConstant() basic function test +--FILE-- +getConstant('a')); + var_dump($rc->getConstant('doesntexist')); +} +?> +--EXPECTF-- +Reflecting on instance of class C: +string(12) "hello from C" +bool(false) +Reflecting on instance of class D: +string(12) "hello from C" +bool(false) +Reflecting on instance of class E: +string(12) "hello from C" +bool(false) +Reflecting on instance of class F: +string(12) "hello from F" +bool(false) +Reflecting on instance of class X: +bool(false) +bool(false) +--UEXPECTF-- +Reflecting on instance of class C: +unicode(12) "hello from C" +bool(false) +Reflecting on instance of class D: +unicode(12) "hello from C" +bool(false) +Reflecting on instance of class E: +unicode(12) "hello from C" +bool(false) +Reflecting on instance of class F: +unicode(12) "hello from F" +bool(false) +Reflecting on instance of class X: +bool(false) +bool(false) diff --git a/ext/reflection/tests/reflectionObject_getConstant_error.phpt b/ext/reflection/tests/reflectionObject_getConstant_error.phpt new file mode 100644 index 0000000000..d16132b202 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstant_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +ReflectionObject::getConstant() - invalid params +--FILE-- +getConstant()); +var_dump($rc->getConstant("myConst", "myConst")); +var_dump($rc->getConstant(null)); +var_dump($rc->getConstant(1)); +var_dump($rc->getConstant(1.5)); +var_dump($rc->getConstant(true)); +var_dump($rc->getConstant(array(1,2,3))); +var_dump($rc->getConstant(new C)); +?> +--EXPECTF-- +Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 7 +NULL + +Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 8 +NULL +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 13 +NULL + +Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 14 +NULL +--UEXPECTF-- +Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 0 given in %s on line 7 +NULL + +Warning: ReflectionClass::getConstant() expects exactly 1 parameter, 2 given in %s on line 8 +NULL +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), array given in %s on line 13 +NULL + +Warning: ReflectionClass::getConstant() expects parameter 1 to be string (Unicode or binary), object given in %s on line 14 +NULL diff --git a/ext/reflection/tests/reflectionObject_getConstants_basic.phpt b/ext/reflection/tests/reflectionObject_getConstants_basic.phpt new file mode 100644 index 0000000000..68bc5d6b8b --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstants_basic.phpt @@ -0,0 +1,73 @@ +--TEST-- +ReflectionObject::getConstants() - basic function test +--FILE-- +getConstants()); +} + +?> +--EXPECTF-- +Reflecting on instance of class C: +array(1) { + ["a"]=> + string(12) "hello from C" +} +Reflecting on instance of class D: +array(1) { + ["a"]=> + string(12) "hello from C" +} +Reflecting on instance of class E: +array(1) { + ["a"]=> + string(12) "hello from C" +} +Reflecting on instance of class F: +array(1) { + ["a"]=> + string(12) "hello from F" +} +Reflecting on instance of class X: +array(0) { +} +--UEXPECTF-- +Reflecting on instance of class C: +array(1) { + [u"a"]=> + unicode(12) "hello from C" +} +Reflecting on instance of class D: +array(1) { + [u"a"]=> + unicode(12) "hello from C" +} +Reflecting on instance of class E: +array(1) { + [u"a"]=> + unicode(12) "hello from C" +} +Reflecting on instance of class F: +array(1) { + [u"a"]=> + unicode(12) "hello from F" +} +Reflecting on instance of class X: +array(0) { +} diff --git a/ext/reflection/tests/reflectionObject_getConstants_error.phpt b/ext/reflection/tests/reflectionObject_getConstants_error.phpt new file mode 100644 index 0000000000..0d16c17f0b --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstants_error.phpt @@ -0,0 +1,22 @@ +--TEST-- +ReflectionObject::getConstants() - invalid params +--FILE-- +getConstants('X'); +$rc->getConstants(true); + +?> +--EXPECTF-- +Warning: Wrong parameter count for ReflectionClass::getConstants() in %s on line 7 + +Warning: Wrong parameter count for ReflectionClass::getConstants() in %s on line 8 +--UEXPECTF-- +Warning: Wrong parameter count for ReflectionClass::getConstants() in %s on line 7 + +Warning: Wrong parameter count for ReflectionClass::getConstants() in %s on line 8 + diff --git a/ext/reflection/tests/reflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/reflectionObject_getConstructor_basic.phpt new file mode 100644 index 0000000000..5014f47100 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstructor_basic.phpt @@ -0,0 +1,99 @@ +--TEST-- +ReflectionObject::getConstructor() - basic function test +--FILE-- +getConstructor(); + if ($rm != null) { + echo "Constructor of $class: " . $rm->getName() . "\n"; + } else { + echo "No constructor for $class\n"; + } + +} + +?> +--EXPECTF-- + +Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 + +Strict Standards: %s for class NewAndOldCtor in %s on line 31 +Constructor of NewCtor: __construct +Constructor of ExtendsNewCtor: __construct +Constructor of OldCtor: OldCtor +Constructor of ExtendsOldCtor: OldCtor +Constructor of OldAndNewCtor: __construct +Constructor of NewAndOldCtor: __construct +Constructor of B: B +Constructor of C: C +Constructor of D1: __construct +Constructor of D2: C +No constructor for X +No constructor for Y +--UEXPECTF-- + +Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26 + +Strict Standards: %s for class NewAndOldCtor in %s on line 31 +Constructor of NewCtor: __construct +Constructor of ExtendsNewCtor: __construct +Constructor of OldCtor: OldCtor +Constructor of ExtendsOldCtor: OldCtor +Constructor of OldAndNewCtor: __construct +Constructor of NewAndOldCtor: __construct +Constructor of B: B +Constructor of C: C +Constructor of D1: __construct +Constructor of D2: C +No constructor for X +No constructor for Y diff --git a/ext/reflection/tests/reflectionObject_getConstructor_error.phpt b/ext/reflection/tests/reflectionObject_getConstructor_error.phpt new file mode 100644 index 0000000000..73ac55f06c --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getConstructor_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +ReflectionObject::getConstructor() - invalid params +--FILE-- +getConstructor(null)); +var_dump($rc->getConstructor('X')); +var_dump($rc->getConstructor(true)); +var_dump($rc->getConstructor(array(1,2,3))); +?> +--EXPECTF-- + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 5 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 6 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 7 +NULL +--UEXPECTF-- + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 5 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 6 +NULL + +Warning: Wrong parameter count for ReflectionClass::getConstructor() in %s on line 7 +NULL diff --git a/ext/reflection/tests/reflectionObject_getName_basic.phpt b/ext/reflection/tests/reflectionObject_getName_basic.phpt new file mode 100644 index 0000000000..c3fc65c96d --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getName_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +ReflectionObject::getName() - basic function test +--FILE-- +getName()); + +$r1 = new ReflectionObject(new stdClass); +var_dump($r1->getName()); + +class C { } +$myInstance = new C; +$r2 = new ReflectionObject($myInstance); +var_dump($r2->getName()); + +$r3 = new ReflectionObject($r2); +var_dump($r3->getName()); + +?> +--EXPECTF-- + +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 2 +string(0) "" +string(8) "stdClass" +string(1) "C" +string(16) "ReflectionObject" +--UEXPECTF-- + +Warning: ReflectionObject::__construct() expects exactly 1 parameter, 0 given in %s on line 2 +unicode(0) "" +unicode(8) "stdClass" +unicode(1) "C" +unicode(16) "ReflectionObject" + diff --git a/ext/reflection/tests/reflectionObject_getName_error.phpt b/ext/reflection/tests/reflectionObject_getName_error.phpt new file mode 100644 index 0000000000..a636ddc835 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getName_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +ReflectionObject::getname() - invalid params +--FILE-- +getName(null)); +var_dump($r3->getName('x','y')); +var_dump($r3->getName(0)); +?> +--EXPECTF-- +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 8 +NULL + +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 10 +NULL +--UEXPECTF-- +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 8 +NULL + +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 9 +NULL + +Warning: Wrong parameter count for ReflectionClass::getName() in %s on line 10 +NULL diff --git a/ext/reflection/tests/reflectionObject_getName_error1.phpt b/ext/reflection/tests/reflectionObject_getName_error1.phpt new file mode 100644 index 0000000000..1622683285 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_getName_error1.phpt @@ -0,0 +1,10 @@ +--TEST-- +ReflectionObject::getName - forbid static invocation +--FILE-- + +--EXPECTF-- +Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2 +--UEXPECTF-- +Fatal error: Non-static method ReflectionClass::getName() cannot be called statically in %s on line 2 diff --git a/ext/reflection/tests/reflectionObject_isInstance_basic.phpt b/ext/reflection/tests/reflectionObject_isInstance_basic.phpt new file mode 100644 index 0000000000..c317f0d49c --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInstance_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +ReflectionObject::isInstance() - basic function test +--FILE-- + new A, + "myB" => new B, + "myX" => new X ); + +foreach ($classes as $class) { + $ro = new ReflectionObject(new $class); + foreach ($instances as $name => $instance) { + echo "is $name a $class? "; + var_dump($ro->isInstance($instance)); + } +} + +?> +--EXPECTF-- +is myA a A? bool(true) +is myB a A? bool(false) +is myX a A? bool(false) +is myA a B? bool(false) +is myB a B? bool(true) +is myX a B? bool(false) +is myA a X? bool(false) +is myB a X? bool(false) +is myX a X? bool(true) +--UEXPECTF-- +is myA a A? bool(true) +is myB a A? bool(false) +is myX a A? bool(false) +is myA a B? bool(false) +is myB a B? bool(true) +is myX a B? bool(false) +is myA a X? bool(false) +is myB a X? bool(false) +is myX a X? bool(true) diff --git a/ext/reflection/tests/reflectionObject_isInstance_error.phpt b/ext/reflection/tests/reflectionObject_isInstance_error.phpt new file mode 100644 index 0000000000..a24a1f5141 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInstance_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +ReflectionObject::isInstance() - invalid params +--FILE-- +isInstance()); +var_dump($ro->isInstance($instance, $instance)); +var_dump($ro->isInstance(1)); +var_dump($ro->isInstance(1.5)); +var_dump($ro->isInstance(true)); +var_dump($ro->isInstance('X')); +var_dump($ro->isInstance(null)); + +?> +--EXPECTF-- +Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 6 +NULL + +Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 7 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, integer given in %s on line 8 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 9 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 10 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, string given in %s on line 11 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 12 +NULL +--UEXPECTF-- +Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 0 given in %s on line 6 +NULL + +Warning: ReflectionClass::isInstance() expects exactly 1 parameter, 2 given in %s on line 7 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, integer given in %s on line 8 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, double given in %s on line 9 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, boolean given in %s on line 10 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, Unicode string given in %s on line 11 +NULL + +Warning: ReflectionClass::isInstance() expects parameter 1 to be object, null given in %s on line 12 +NULL diff --git a/ext/reflection/tests/reflectionObject_isInstantiable_basic.phpt b/ext/reflection/tests/reflectionObject_isInstantiable_basic.phpt new file mode 100644 index 0000000000..0966359dbf --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInstantiable_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +ReflectionObject::IsInstantiable() - basic function test +--FILE-- +IsInstantiable()); +} +?> +--EXPECTF-- +Is C instantiable? bool(true) +Is ifaceImpl instantiable? bool(true) +Is D instantiable? bool(true) +--UEXPECTF-- +Is C instantiable? bool(true) +Is ifaceImpl instantiable? bool(true) +Is D instantiable? bool(true) diff --git a/ext/reflection/tests/reflectionObject_isInstantiable_error.phpt b/ext/reflection/tests/reflectionObject_isInstantiable_error.phpt new file mode 100644 index 0000000000..04ff50b7e5 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInstantiable_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +ReflectionObject::IsInstantiable() - invalid params +--FILE-- +IsInstantiable('X')); +var_dump($reflectionObject->IsInstantiable(0, null)); + +?> +--EXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 10 +NULL + +Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 11 +NULL +--UEXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 10 +NULL + +Warning: Wrong parameter count for ReflectionClass::isInstantiable() in %s on line 11 +NULL diff --git a/ext/reflection/tests/reflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/reflectionObject_isInstantiable_variation.phpt new file mode 100644 index 0000000000..3f5d57ce4c --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInstantiable_variation.phpt @@ -0,0 +1,86 @@ +--TEST-- +ReflectionObject::IsInstantiable() - variation - constructors +--FILE-- +getName(); + echo "Is $name instantiable? "; + var_dump($reflectionObject->IsInstantiable()); +} +?> +--EXPECTF-- +Is noCtor instantiable? bool(true) +Is publicCtorNew instantiable? bool(true) +Is protectedCtorNew instantiable? bool(false) +Is privateCtorNew instantiable? bool(false) +Is publicCtorOld instantiable? bool(true) +Is protectedCtorOld instantiable? bool(false) +Is privateCtorOld instantiable? bool(false) +--UEXPECTF-- +Is noCtor instantiable? bool(true) +Is publicCtorNew instantiable? bool(true) +Is protectedCtorNew instantiable? bool(false) +Is privateCtorNew instantiable? bool(false) +Is publicCtorOld instantiable? bool(true) +Is protectedCtorOld instantiable? bool(false) +Is privateCtorOld instantiable? bool(false) diff --git a/ext/reflection/tests/reflectionObject_isInternal_basic.phpt b/ext/reflection/tests/reflectionObject_isInternal_basic.phpt new file mode 100644 index 0000000000..2161251804 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInternal_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +ReflectionObject::isInternal() - basic function test +--FILE-- +isInternal(), $r2->isInternal(), $r3->isInternal(), + $r4->isInternal(), $r5->isInternal()); + +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +--UEXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/ext/reflection/tests/reflectionObject_isInternal_error.phpt b/ext/reflection/tests/reflectionObject_isInternal_error.phpt new file mode 100644 index 0000000000..0ac2d21f5e --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isInternal_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +ReflectionObject::isInternal() - invalid params +--FILE-- +isInternal('X')); +var_dump($r1->isInternal('X', true)); +?> +--EXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 5 +NULL +--UEXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::isInternal() in %s on line 5 +NULL diff --git a/ext/reflection/tests/reflectionObject_isSubclassOf_basic.phpt b/ext/reflection/tests/reflectionObject_isSubclassOf_basic.phpt new file mode 100644 index 0000000000..5687d381ec --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isSubclassOf_basic.phpt @@ -0,0 +1,193 @@ +--TEST-- +ReflectionObject::isSubclassOf() - basic function test +--FILE-- +isInstantiable()) { + $ros[$className] = new ReflectionObject(new $className); + } +} + +foreach ($ros as $childName => $child) { + foreach ($rcs as $parentName => $parent) { + echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; + echo " - Using ReflectionClass object argument: "; + var_dump($child->isSubclassOf($parent)); + if ($parent->isInstantiable()) { + echo " - Using ReflectionObject object argument: "; + var_dump($child->isSubclassOf($ros[$parentName])); + } + echo " - Using string argument: "; + var_dump($child->isSubclassOf($parentName)); + } +} +?> +--EXPECTF-- +Is A a subclass of A? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of A? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is B a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of A? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is C a subclass of B? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is C a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of A? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of I? + - Using ReflectionClass object argument: bool(true) + - Using string argument: bool(true) +Is X a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +--UEXPECTF-- +Is A a subclass of A? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is A a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of A? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is B a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is B a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of A? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is C a subclass of B? + - Using ReflectionClass object argument: bool(true) + - Using ReflectionObject object argument: bool(true) + - Using string argument: bool(true) +Is C a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of I? + - Using ReflectionClass object argument: bool(false) + - Using string argument: bool(false) +Is C a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of A? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of B? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of C? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) +Is X a subclass of I? + - Using ReflectionClass object argument: bool(true) + - Using string argument: bool(true) +Is X a subclass of X? + - Using ReflectionClass object argument: bool(false) + - Using ReflectionObject object argument: bool(false) + - Using string argument: bool(false) diff --git a/ext/reflection/tests/reflectionObject_isSubclassOf_error.phpt b/ext/reflection/tests/reflectionObject_isSubclassOf_error.phpt new file mode 100644 index 0000000000..61db821a4e --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isSubclassOf_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +ReflectionObject::isSubclassOf() - invalid params +--FILE-- +isSubclassOf()); +var_dump($ro->isSubclassOf('A',5)); +var_dump($ro->isSubclassOf('X')); + +?> +--EXPECTF-- +Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 5 +NULL + +Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 6 +NULL + +Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:7 +Stack trace: +#0 %s(7): ReflectionClass->isSubclassOf('X') +#1 {main} + thrown in %s on line 7 +--UEXPECTF-- +Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 0 given in %s on line 5 +NULL + +Warning: ReflectionClass::isSubclassOf() expects exactly 1 parameter, 2 given in %s on line 6 +NULL + +Fatal error: Uncaught exception 'ReflectionException' with message 'Class X does not exist' in %s:7 +Stack trace: +#0 %s(7): ReflectionClass->isSubclassOf('X') +#1 {main} + thrown in %s on line 7 diff --git a/ext/reflection/tests/reflectionObject_isUserDefined_basic.phpt b/ext/reflection/tests/reflectionObject_isUserDefined_basic.phpt new file mode 100644 index 0000000000..7861b49855 --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isUserDefined_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +ReflectionObject::isUserDefined() - basic function test +--FILE-- +isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), + $r4->isUserDefined(), $r5->isUserDefined()); + +?> +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +--UEXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) diff --git a/ext/reflection/tests/reflectionObject_isUserDefined_error.phpt b/ext/reflection/tests/reflectionObject_isUserDefined_error.phpt new file mode 100644 index 0000000000..eecccc420c --- /dev/null +++ b/ext/reflection/tests/reflectionObject_isUserDefined_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +ReflectionObject::isUserDefined() - invalid params +--FILE-- +isUserDefined('X')); +var_dump($r1->isUserDefined('X', true)); +?> +--EXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 5 +NULL +--UEXPECTF-- +Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 4 +NULL + +Warning: Wrong parameter count for ReflectionClass::isUserDefined() in %s on line 5 +NULL