Welcome Guest, Not a member yet? Register   Sign In
Unit Testing for Matchbox?
#1

[eluser]Andreas Krohn[/eluser]
I am looking for a good unit testing framework to use with Matchbox. I like TOAST but it doesnt play nicely with matchbox and CodeIgniters own Unit Test Class is a bit simplistic for my taste. Are there any such unit test frameworks ready to be used?

Grateful for any suggestions!
#2

[eluser]Phil Sturgeon[/eluser]
Why are you still using Matchbox? It has been dead in the water for months. Almost a year?

Anyhow, what problems are you having? "Not playing nicely" is a bit vague. ;-)
#3

[eluser]Andreas Krohn[/eluser]
You dont think that "not playing nicely" is a thorough enough explanation, how strange Smile I am having problems with getting TOAST to find my tests and to find the TOAST views. Do not know exactly why yet, but I am working on it (hence the vague description of my problem).

I am mainly using matchbox out of habit and since I am usually using BackendPro (not in the project though). If there is an alternative that is alive, that it is not to much work to migrate to from matchbox and that I can do proper unit testing with I am all for that. Any suggestions?

Btw Phil, I really love your REST Server lib!
#4

[eluser]Phil Sturgeon[/eluser]
I migrated PyroCMS from Matchbox to Modular Separation (now Modular Extensions) in about 30 minutes. Easy peasy.

Paste up some code so we can help?
#5

[eluser]Andreas Krohn[/eluser]
Did some changes in Toast_all.php so now I can have unit tests in each of the Matchbox modules instead of centralized in the app/controllers/test directory. Adding the method below to Toast_all and using it in index() to get the $test_urls is all I did. Module unit tests are then placed in a new directory called "test" in each modules controllers directory.

Code:
function _get_test_urls()
    {
        $test_urls = array();
        
        $module_handle = opendir(APPPATH . 'modules');
        while (false !== ($module = readdir($module_handle)))
        {
            if ( ! in_array($module, $this->skip) && ! (substr($module, 0, 1) == '.'))
            {
                $test_dir = APPPATH . 'modules/'.$module.'/controllers'.$this->test_dir;
                if (!is_dir($test_dir))
                {
                    continue;
                }
                $handle = opendir($test_dir);
                while (false !== ($file = readdir($handle)))
                {
                    if ( ! in_array($file, $this->skip) && ! (substr($file, 0, 1) == '.'))
                    {        
                        // Remove the '.php' part of the file name
                        $file_name = substr($file, 0, strlen($file) - 4);
                        $test_urls[] = site_url($module.$this->test_dir.$file_name);
                    }
                } //while file handle    
                
                closedir($handle);    
            }                
        } //while module handle
        closedir($module_handle);
        
        return $test_urls;
    }

Moving from Matchbox to Modular Extension is added to my todo list. My changes to Toast should work either way.




Theme © iAndrew 2016 - Forum software by © MyBB