CodeIgniter Forums
codeigniter + simple test??? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: codeigniter + simple test??? (/showthread.php?tid=14495)



codeigniter + simple test??? - El Forum - 01-05-2009

[eluser]gulan[/eluser]
Hi all...

Somebody please tell me how to do simpletest (unit test) for php files which is in codeigniter frame work????


Thanks
gulan


codeigniter + simple test??? - El Forum - 01-20-2009

[eluser]geshan[/eluser]
I also want to know about it.


codeigniter + simple test??? - El Forum - 01-20-2009

[eluser]Mark Skilbeck[/eluser]
Let met google that for you


codeigniter + simple test??? - El Forum - 01-20-2009

[eluser]gon[/eluser]
This works if you have simpletest in your php.ini include_path.

Code:
<?php

require_once("unit_tester.php");
require_once('reporter.php');

class Test extends Controller {

    function Test()
    {    
        parent::Controller();
                    
        $this->test =& new TestSuite('AllTests');
        
        $this->test->addTestFile(APPPATH.'test/testXMLBaseParser.php');
        $this->test->addTestFile(APPPATH.'test/testReslib.php');            
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyMethods.php');
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyFixture1.php');        
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyFixture2.php');
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyFixture3.php');
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyFixture4.php');
        $this->test->addTestFile(APPPATH.'test/testPurchaseCancellationPolicyFixture5.php');
        
          
       // ... lots of test classes
        
        
    }
    
    function index(){    
        $this->test->run(new HtmlReporter());    
            
    }
    
    function text() {        
        $this->test->run(new TextReporter());
    }
    function xml() {
        $this->test->run(new XmlReporter());
    }    
    
}
?>