Versions
Look up a class, method, property or event

CTestCase

Package system.test
Inheritance abstract class CTestCase
Subclasses CDbTestCase
Since 1.1
Source Code framework/test/CTestCase.php
CTestCase is the base class for all test case classes.

Total 1 comment

#5802 report it
pligor at 2011/11/14 03:44pm
unit tests related

Since you are probably already writing simple tests for class methods here is a small snippet of code to use in your tests. The convetion is that you name your simple tests after the method that you are testing. So you have function methodName() { ... } and the corresponding test is named testMethodName() { .. } The second convetion is that the test class is named with test appended to original class name. so class ClassName { ..... } and the test class is named class ClassNameTest extends CDbTestCase { .... }

So..

$func = lcfirst( substr(__FUNCTION__, strlen('test')) );
$class = substr(__CLASS__, 0, -strlen('test'));
$model = new $class();
$function = array($model, $func);

and for seemingly for static methods:

$func = lcfirst( substr(__FUNCTION__, strlen('test')) );
$class = substr(__CLASS__, 0, -strlen('test'));
$function = array($class, $func);

Afterwards you simply use the php function:

$returnVal = call_user_func($function,$param1,$param2,..);

Leave a comment

Please to leave your comment.