2005-05-22 23:24:09 +00:00
|
|
|
<?PHP
|
2005-06-05 04:43:07 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// + $Id$
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
// + Cake <https://developers.nextco.com/cake/> + //
|
|
|
|
// + Copyright: (c) 2005, Cake Authors/Developers + //
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
// + Licensed under The MIT License + //
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2005-05-22 23:24:09 +00:00
|
|
|
|
2005-06-05 04:43:07 +00:00
|
|
|
|
|
|
|
/**
|
2005-06-05 23:41:46 +00:00
|
|
|
* The includes below are required for the TestsController to work.
|
2005-06-05 04:43:07 +00:00
|
|
|
*/
|
2005-05-22 23:24:09 +00:00
|
|
|
uses('test', 'folder', 'inflector');
|
|
|
|
|
|
|
|
class TestsController extends TestsHelper {
|
|
|
|
|
2005-05-31 23:18:22 +00:00
|
|
|
/**
|
2005-06-05 23:41:46 +00:00
|
|
|
* Runs all library and application tests
|
|
|
|
*
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.app
|
2005-05-31 23:18:22 +00:00
|
|
|
*/
|
2005-06-05 23:41:46 +00:00
|
|
|
function test_all ()
|
|
|
|
{
|
2005-05-22 23:24:09 +00:00
|
|
|
$this->layout = 'test';
|
|
|
|
|
|
|
|
$tests_folder = new Folder('../tests');
|
|
|
|
|
|
|
|
$results = array();
|
|
|
|
$total_errors = 0;
|
2005-06-05 23:41:46 +00:00
|
|
|
foreach ($tests_folder->findRecursive('.*\.php') as $test)
|
|
|
|
{
|
|
|
|
if (preg_match('/^(.+)\.php/i', basename($test), $r))
|
|
|
|
{
|
2005-05-22 23:24:09 +00:00
|
|
|
require_once($test);
|
|
|
|
$test_name = Inflector::Camelize($r[1]);
|
2005-06-05 23:41:46 +00:00
|
|
|
if (preg_match('/^(.+)Test$/i', $test_name, $r))
|
|
|
|
{
|
2005-05-22 23:24:09 +00:00
|
|
|
$module_name = $r[1];
|
|
|
|
}
|
2005-06-05 23:41:46 +00:00
|
|
|
else
|
|
|
|
{
|
2005-05-22 23:24:09 +00:00
|
|
|
$module_name = $test_name;
|
|
|
|
}
|
|
|
|
$suite = new TestSuite($test_name);
|
|
|
|
$result = TestRunner::run($suite);
|
|
|
|
|
|
|
|
$total_errors += $result['errors'];
|
|
|
|
|
2005-06-05 23:41:46 +00:00
|
|
|
$results[] = array
|
|
|
|
(
|
2005-05-22 23:24:09 +00:00
|
|
|
'name'=>$module_name,
|
|
|
|
'result'=>$result,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->set('success', !$total_errors);
|
|
|
|
$this->set('results', $results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|