How to implement SimpleTest in Cohan

My boss instructed me to learn how to use Cohan and implement a simple test. We would like to use it as a basis for future projects.

Being new to KohanaPHP and SimpleTest , I cannot figure out how to make even the simplest test of my assistants. I can’t even find a step-by-step guide on connecting SimpleTest to Kohana.

Does anyone have an idea?

+4
source share
1 answer

We created SimpleTest_controller in Cohan

and he gets a test from catalog tests

define ( 'SIMPLE_TEST', '../tools/simpletest/'); require_once(SIMPLE_TEST . 'unit_tester.php'); require_once(SIMPLE_TEST . 'reporter.php'); require_once( SIMPLE_TEST . 'mock_objects.php'); class SimpleTest_Controller extends Controller { function index() { $this->runall(); } function runall() { $sDir = '../tests/'; $rDir = opendir( $sDir ); while ( $sFile = readdir( $rDir ) ) { if ( $sFile != '.' && $sFile != '..' ) { $this->run( $sFile ); } } } function run ( $sTests ) { $sDir = '../tests/' . $sTests .'/'; $rDir = opendir( $sDir ); $test = new GroupTest( $sTests ); while ( $sFile = readdir( $rDir ) ) { if ( $sFile != '.' && $sFile != '..' && !preg_match('/~\d+~/', $sFile) ) { include_once($sDir . $sFile); $test->addTestCase( substr($sFile, 0, -4 ) ); } } $test->run( new HtmlReporter() ); } } 

you can call domain.com/simpletest to start everything or you can call domain.com/simpletest/run/account if you have an account in the test folder

+4
source

All Articles