now you just need to write your test class with tegst methods prefixed by 'test', and then just instantiate object of that test class of your, all those tests methods will get run automaticallyThe drawback is: your test methods must not accept any arguments

an example:require '../autoload.php';register_autoload_paths(realpath('./'));

In PHP4, this function converts its return values to lowercase; but in PHP5, it leaves the return values in their original case. This can cause serious problems when trying to write code that dynamically calls a class method, and that works in both PHP4 and PHP5. This code snippet shows one way of achieving compatibility with both versions:

// Use array_map() and strtolower() to make all values returned by get_class_methods() lowercase. PHP4 does this anyway - now it will happen regardless of the PHP version being used.$classMethods = array_map(strtolower, get_class_methods($className));

// in_array() can only handle being given an array.if (!$classMethods) {$classMethods = array();}

Note that this function will answer both class AND instance methods ("class methods" are called "static" in PHP). Sort of a little "trap" for people who have in-depth experience with the OO terminology :-)

If you want to get all methods/functions from a class you can do this with the get_class_methods function.<?php $arrMethodNames = get_class_methods ( $ClassNameOrObject);?>However the drawback on this function in PHP5 is that you will NOT receive protected and private methods of a class/object if you are calling the method from another class/object context.

If you want to receive all methods of a given Class in another Class you should use the PHP5 Reflection API. The following source allows to retrieve all methods from a derived class in its (abstract) Base Class.

In the example you need to call the base constructor from the derived classes constructor in order to let the base class know the name of the derived class. Use the "__CLASS__" definition for passing the classname of current class to its base class.

<?php

// Base Class - Abstractabstract class A {

// Array of ReflectionMethod Objects // is being set upon instanciation // derived Classes don't need to know about this arrayprivate $arrMethods;

// Create new B Object$b = new B();// Print all Methods of this Object/Class$b->PrintAllMethods();?>

In this example output will be:

__constructABCDEPrintAllMethods

As you can see these are all methods from class B and also all methods from Class A respectivly in order of their declaration. Note that only one method "__construct" and only one method "D" are being shown. This is due to overloading (__construct) and implementing (D) in PHP.

In this example any further method-handling methods should be implemented in the base class as these will be available in derived classes as well. Just make sure that you use the right access specifiers for these additional methods ( private, protected, public )

I've figured out how to get around my issue described below, using the Reflection API.

<?/* Pass the name of the class, not a declared handler */function get_public_methods($className) { /* Init the return array */ $returnArray = array();

/* Iterate through each method in the class */ foreach (get_class_methods($className) as $method) {

/* Get a reflection object for the class method */ $reflect = new ReflectionMethod($className, $method);

/* For private, use isPrivate(). For protected, use isProtected() */ /* See the Reflection API documentation for more definitions */ if($reflect->isPublic()) { /* The method is one we're looking for, push it onto the return array */ array_push($returnArray,$method); } }