2006-10-01 17:54:15 +04:00
< ? php
2007-01-29 23:10:51 +03:00
ini_set ( 'max_execution_time' , 900 );
2007-09-29 16:31:56 +04:00
ini_set ( " date.timezone " , " GMT+0 " );
2006-10-01 17:54:15 +04:00
2007-09-03 01:51:04 +04:00
function parseOptions ( $array ) {
2007-09-03 02:34:02 +04:00
$currentName = '' ;
2007-09-03 02:29:15 +04:00
$options = array ();
foreach ( $array as $name ) {
2007-09-03 19:18:12 +04:00
if ( strpos ( $name , '-' ) === 0 ) {
2007-09-03 02:34:02 +04:00
$name = str_replace ( '-' , '' , $name );
2007-09-03 02:29:15 +04:00
$currentName = $name ;
2007-09-03 19:18:12 +04:00
if ( ! isset ( $options [ $currentName ])) {
2007-09-03 02:29:15 +04:00
$options [ $currentName ] = array ();
}
} else {
$values = $options [ $currentName ];
array_push ( $values , $name );
$options [ $currentName ] = $values ;
}
2007-09-03 01:51:04 +04:00
}
2007-09-03 02:29:15 +04:00
return $options ;
2007-09-03 01:51:04 +04:00
}
2006-12-28 00:20:26 +03:00
function autoload ( $class ) {
2007-09-03 19:18:12 +04:00
if ( strpos ( $class , 'TestCase' ) === false ) {
2006-12-28 00:20:26 +03:00
return false ;
2007-07-06 16:37:02 +04:00
}
2006-11-28 21:39:31 +03:00
2006-12-28 00:20:26 +03:00
$e = explode ( '_' , $class );
$count = count ( $e );
2006-10-01 17:54:15 +04:00
2007-06-01 14:17:50 +04:00
$prefix = array_shift ( $e );
if ( $prefix !== 'Doctrine' ) {
return false ;
}
2006-11-28 01:49:13 +03:00
2006-12-28 00:20:26 +03:00
$dir = array_shift ( $e );
2006-12-02 17:40:47 +03:00
2006-12-28 00:20:26 +03:00
$file = $dir . '_' . substr ( implode ( '_' , $e ), 0 , - ( strlen ( '_TestCase' ))) . 'TestCase.php' ;
2006-12-02 17:40:47 +03:00
2007-09-03 19:18:12 +04:00
if ( $count > 3 ) {
2006-12-28 00:20:26 +03:00
$file = str_replace ( '_' , DIRECTORY_SEPARATOR , $file );
} else {
$file = str_replace ( '_' , '' , $file );
}
2007-04-18 23:03:36 +04:00
2006-12-28 00:20:26 +03:00
// create a test case file if it doesn't exist
2006-12-02 17:40:47 +03:00
2007-06-01 14:17:50 +04:00
if ( ! file_exists ( $file )) {
2006-12-28 00:20:26 +03:00
$contents = file_get_contents ( 'template.tpl' );
$contents = sprintf ( $contents , $class , $class );
2006-12-02 23:51:26 +03:00
2007-09-03 19:18:12 +04:00
if ( ! file_exists ( $dir )) {
2006-12-28 00:20:26 +03:00
mkdir ( $dir , 0777 );
}
2006-11-28 01:49:13 +03:00
2006-12-28 00:20:26 +03:00
file_put_contents ( $file , $contents );
}
require_once ( $file );
2007-04-18 23:28:21 +04:00
2006-12-28 00:20:26 +03:00
return true ;
}
2006-11-28 01:49:13 +03:00
2007-04-18 23:28:21 +04:00
// include doctrine, and register it's autoloader
2006-12-28 00:20:26 +03:00
require_once dirname ( __FILE__ ) . '/../lib/Doctrine.php' ;
spl_autoload_register ( array ( 'Doctrine' , 'autoload' ));
2007-04-18 23:28:21 +04:00
// register the autoloader function above
2006-12-28 00:20:26 +03:00
spl_autoload_register ( 'autoload' );
2006-11-30 00:09:02 +03:00
2007-09-02 18:24:49 +04:00
// include the models
$models = new DirectoryIterator ( dirname ( __FILE__ ) . '/../models/' );
foreach ( $models as $key => $file ) {
if ( $file -> isFile () && ! $file -> isDot ()) {
2007-09-03 20:31:35 +04:00
$e = explode ( '.' , $file -> getFileName ());
if ( end ( $e ) === 'php' ) {
require_once $file -> getPathname ();
}
2007-09-02 18:24:49 +04:00
}
}
2007-06-27 21:41:02 +04:00
2007-06-01 14:17:50 +04:00
require_once dirname ( __FILE__ ) . '/Test.php' ;
2007-04-18 23:28:21 +04:00
require_once dirname ( __FILE__ ) . '/UnitTestCase.php' ;
2007-01-10 01:59:15 +03:00
2007-06-07 21:04:56 +04:00
error_reporting ( E_ALL | E_STRICT );
2006-11-24 02:23:24 +03:00
2006-12-28 00:20:26 +03:00
$test = new GroupTest ( 'Doctrine Framework Unit Tests' );
2006-11-24 02:23:24 +03:00
2007-09-02 20:43:41 +04:00
//TICKET test cases
2007-09-03 22:34:43 +04:00
$tickets = new GroupTest ( 'Tickets tests' );
$tickets -> addTestCase ( new Doctrine_Ticket_Njero_TestCase ());
2007-09-04 01:13:31 +04:00
$tickets -> addTestCase ( new Doctrine_Ticket_428_TestCase ());
2007-09-03 19:18:12 +04:00
//If you write a ticket testcase add it here like shown above!
2007-09-03 22:34:43 +04:00
$test -> addTestCase ( $tickets );
2007-07-14 18:31:34 +04:00
2007-01-01 21:36:37 +03:00
// Connection drivers (not yet fully tested)
2007-09-03 19:18:12 +04:00
$driver = new GroupTest ( " Driver tests " );
$driver -> addTestCase ( new Doctrine_Connection_Pgsql_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Oracle_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Sqlite_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Mssql_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Mysql_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Firebird_TestCase ());
$driver -> addTestCase ( new Doctrine_Connection_Informix_TestCase ());
$test -> addTestCase ( $driver );
2007-01-06 01:13:44 +03:00
2007-01-01 21:36:37 +03:00
// Transaction module (FULLY TESTED)
2007-09-03 19:18:12 +04:00
$transaction = new GroupTest ( " Transaction tests " );
$transaction -> addTestCase ( new Doctrine_Transaction_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Firebird_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Informix_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Mysql_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Mssql_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Pgsql_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Oracle_TestCase ());
$transaction -> addTestCase ( new Doctrine_Transaction_Sqlite_TestCase ());
$test -> addTestCase ( $transaction );
2006-12-24 01:45:36 +03:00
2007-01-01 21:36:37 +03:00
// DataDict module (FULLY TESTED)
2007-09-03 22:19:37 +04:00
$data_dict = new GroupTest ( 'DataDict tests' );
$data_dict -> addTestCase ( new Doctrine_DataDict_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Firebird_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Informix_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Mysql_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Mssql_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Pgsql_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Oracle_TestCase ());
$data_dict -> addTestCase ( new Doctrine_DataDict_Sqlite_TestCase ());
$test -> addTestCase ( $data_dict );
2007-01-01 21:36:37 +03:00
2007-01-08 02:52:15 +03:00
// Sequence module (not yet fully tested)
2007-09-03 22:19:37 +04:00
$sequence = new GroupTest ( 'Sequence tests' );
$sequence -> addTestCase ( new Doctrine_Sequence_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Firebird_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Informix_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Mysql_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Mssql_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Pgsql_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Oracle_TestCase ());
$sequence -> addTestCase ( new Doctrine_Sequence_Sqlite_TestCase ());
$test -> addTestCase ( $sequence );
2007-01-08 02:52:15 +03:00
2007-01-01 21:36:37 +03:00
// Export module (not yet fully tested)
2007-09-03 22:19:37 +04:00
$export = new GroupTest ( 'Export tests' );
//$export->addTestCase(new Doctrine_Export_Reporter_TestCase());
$export -> addTestCase ( new Doctrine_Export_Firebird_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Informix_TestCase ());
$export -> addTestCase ( new Doctrine_Export_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Mssql_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Pgsql_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Oracle_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Record_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Mysql_TestCase ());
$export -> addTestCase ( new Doctrine_Export_Sqlite_TestCase ());
$test -> addTestCase ( $export );
2007-02-17 15:38:02 +03:00
2007-06-15 00:42:05 +04:00
//$test->addTestCase(new Doctrine_CascadingDelete_TestCase());
2007-04-11 23:12:52 +04:00
2007-01-01 21:36:37 +03:00
// Import module (not yet fully tested)
2007-09-03 22:19:37 +04:00
$import = new GroupTest ( 'Import tests' );
//$import->addTestCase(new Doctrine_Import_TestCase());
$import -> addTestCase ( new Doctrine_Import_Firebird_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Informix_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Mysql_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Mssql_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Pgsql_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Oracle_TestCase ());
$import -> addTestCase ( new Doctrine_Import_Sqlite_TestCase ());
$test -> addTestCase ( $import );
2006-12-28 00:20:26 +03:00
2007-01-01 21:36:37 +03:00
// Expression module (not yet fully tested)
2007-09-03 22:19:37 +04:00
$expression = new GroupTest ( 'Expression tests' );
$expression -> addTestCase ( new Doctrine_Expression_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Driver_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Firebird_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Informix_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Mysql_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Mssql_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Pgsql_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Oracle_TestCase ());
$expression -> addTestCase ( new Doctrine_Expression_Sqlite_TestCase ());
$test -> addTestCase ( $expression );
2007-06-10 23:40:14 +04:00
2006-12-28 00:20:26 +03:00
// Core
2007-09-03 22:19:37 +04:00
$core = new GroupTest ( 'Core tests: Access, Configurable, Manager, Connection, Table, UnitOfWork, Collection, Hydrate, Tokenizer' );
$core -> addTestCase ( new Doctrine_Access_TestCase ());
//$core->addTestCase(new Doctrine_Configurable_TestCase());
$core -> addTestCase ( new Doctrine_Manager_TestCase ());
$core -> addTestCase ( new Doctrine_Connection_TestCase ());
$core -> addTestCase ( new Doctrine_Table_TestCase ());
$core -> addTestCase ( new Doctrine_UnitOfWork_TestCase ());
//$core->addTestCase(new Doctrine_Collection_TestCase());
$core -> addTestCase ( new Doctrine_Collection_Snapshot_TestCase ());
$core -> addTestCase ( new Doctrine_Hydrate_FetchMode_TestCase ());
$core -> addTestCase ( new Doctrine_Tokenizer_TestCase ());
//$core->addTestCase(new Doctrine_Collection_Offset_TestCase());
//$core->addTestCase(new Doctrine_BatchIterator_TestCase());
//$core->addTestCase(new Doctrine_Hydrate_TestCase());
$test -> addTestCase ( $core );
2007-06-26 00:08:16 +04:00
2006-12-28 00:20:26 +03:00
// Relation handling
2007-09-03 22:19:37 +04:00
$relation = new GroupTest ( 'Relation tests: includes TreeStructure' );
$relation -> addTestCase ( new Doctrine_TreeStructure_TestCase ());
$relation -> addTestCase ( new Doctrine_Relation_TestCase ());
//$relation->addTestCase(new Doctrine_Relation_Access_TestCase());
//$relation->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
$relation -> addTestCase ( new Doctrine_Relation_ManyToMany2_TestCase ());
$relation -> addTestCase ( new Doctrine_Relation_OneToMany_TestCase ());
$relation -> addTestCase ( new Doctrine_Relation_Nest_TestCase ());
$relation -> addTestCase ( new Doctrine_Relation_OneToOne_TestCase ());
$relation -> addTestCase ( new Doctrine_Relation_Parser_TestCase ());
$test -> addTestCase ( $relation );
2007-01-08 02:52:15 +03:00
2006-12-28 00:20:26 +03:00
// Datatypes
2007-09-03 22:19:37 +04:00
$data_types = new GroupTest ( 'DataTypes tests: Enum and Boolean' );
$data_types -> addTestCase ( new Doctrine_DataType_Enum_TestCase ());
$data_types -> addTestCase ( new Doctrine_DataType_Boolean_TestCase ());
$test -> addTestCase ( $data_types );
2006-12-02 17:40:47 +03:00
2006-12-28 00:20:26 +03:00
// Utility components
2007-09-18 01:16:54 +04:00
$plugins = new GroupTest ( 'Plugin tests: View, Validator, Hook' );
2007-09-03 22:19:37 +04:00
//$utility->addTestCase(new Doctrine_PessimisticLocking_TestCase());
2007-09-18 01:16:54 +04:00
$plugins -> addTestCase ( new Doctrine_View_TestCase ());
$plugins -> addTestCase ( new Doctrine_Validator_TestCase ());
2007-09-29 16:31:56 +04:00
$plugins -> addTestCase ( new Doctrine_Validator_Future_TestCase ());
$plugins -> addTestCase ( new Doctrine_Validator_Past_TestCase ());
2007-09-18 01:16:54 +04:00
$plugins -> addTestCase ( new Doctrine_Hook_TestCase ());
2007-10-03 20:30:57 +04:00
//$plugins->addTestCase(new Doctrine_I18n_TestCase());
2007-09-18 01:16:54 +04:00
$test -> addTestCase ( $plugins );
2006-11-16 23:31:39 +03:00
2006-12-28 00:20:26 +03:00
// Db component
2007-09-03 22:19:37 +04:00
$db = new GroupTest ( 'Db tests: Db and Profiler' );
$db -> addTestCase ( new Doctrine_Db_TestCase ());
$db -> addTestCase ( new Doctrine_Connection_Profiler_TestCase ());
$test -> addTestCase ( $db );
2006-11-05 22:24:28 +03:00
2007-02-17 15:38:02 +03:00
// Eventlisteners
2007-09-03 22:19:37 +04:00
$event_listener = new GroupTest ( 'EventListener tests' );
$event_listener -> addTestCase ( new Doctrine_EventListener_TestCase ());
$event_listener -> addTestCase ( new Doctrine_EventListener_Chain_TestCase ());
$test -> addTestCase ( $event_listener );
2007-02-17 15:38:02 +03:00
2007-09-03 22:19:37 +04:00
// Query tests
$query_tests = new GroupTest ( 'Query tests' );
$query_tests -> addTestCase ( new Doctrine_Query_Condition_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_MultiJoin_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_MultiJoin2_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_ReferenceModel_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_ComponentAlias_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_ShortAliases_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Expression_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_OneToOneFetching_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Check_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Limit_TestCase ());
//$query_tests->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$query_tests -> addTestCase ( new Doctrine_Query_Update_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Delete_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Join_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Having_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Orderby_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Subquery_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Driver_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Record_Hook_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_AggregateValue_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Where_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_From_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_Select_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_JoinCondition_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_MultipleAggregateValue_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_MysqlSubquery_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_PgsqlSubquery_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_MysqlSubqueryHaving_TestCase ());
$query_tests -> addTestCase ( new Doctrine_Query_SelectExpression_TestCase ());
2007-09-18 01:16:54 +04:00
$query_tests -> addTestCase ( new Doctrine_Query_Registry_TestCase ());
2007-09-03 22:19:37 +04:00
$test -> addTestCase ( $query_tests );
2006-10-20 22:21:42 +04:00
2007-09-03 22:19:37 +04:00
// Record
$record = new GroupTest ( 'Record tests' );
$record -> addTestCase ( new Doctrine_Record_Filter_TestCase ());
$record -> addTestCase ( new Doctrine_Record_TestCase ());
$record -> addTestCase ( new Doctrine_Record_State_TestCase ());
$record -> addTestCase ( new Doctrine_Record_SerializeUnserialize_TestCase ());
// This test used to segfault php because of infinite recursion in Connection/UnitOfWork
$record -> addTestCase ( new Doctrine_Record_Lock_TestCase ());
$record -> addTestCase ( new Doctrine_Record_ZeroValues_TestCase ());
//$record->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase());
$test -> addTestCase ( $record );
2007-05-27 22:56:54 +04:00
2007-02-17 15:38:02 +03:00
2007-09-02 18:24:49 +04:00
$test -> addTestCase ( new Doctrine_Schema_TestCase ());
2007-05-27 22:56:54 +04:00
2006-12-28 00:20:26 +03:00
$test -> addTestCase ( new Doctrine_CustomPrimaryKey_TestCase ());
2007-06-15 01:48:14 +04:00
$test -> addTestCase ( new Doctrine_CustomResultSetOrder_TestCase ());
2007-02-17 15:38:02 +03:00
2007-04-08 18:55:14 +04:00
$test -> addTestCase ( new Doctrine_ColumnAggregationInheritance_TestCase ());
2007-06-01 14:17:50 +04:00
2007-05-27 22:56:54 +04:00
$test -> addTestCase ( new Doctrine_ColumnAlias_TestCase ());
2007-04-18 23:03:36 +04:00
2007-05-27 22:56:54 +04:00
$test -> addTestCase ( new Doctrine_RawSql_TestCase ());
$test -> addTestCase ( new Doctrine_NewCore_TestCase ());
2007-09-13 00:26:59 +04:00
$test -> addTestCase ( new Doctrine_Template_TestCase ());
2007-06-29 23:23:19 +04:00
2007-09-03 22:19:37 +04:00
//$test->addTestCase(new Doctrine_Import_Builder_TestCase());
2007-07-06 16:37:02 +04:00
2007-07-11 18:39:15 +04:00
2007-06-18 23:58:11 +04:00
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
2007-06-25 23:25:23 +04:00
2007-06-15 01:48:14 +04:00
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
2007-07-21 19:17:17 +04:00
$test -> addTestCase ( new Doctrine_NestedSet_SingleRoot_TestCase ());
2007-07-11 19:55:52 +04:00
2007-09-29 18:35:40 +04:00
// Search tests
$search = new GroupTest ( 'Search tests' );
$search -> addTestCase ( new Doctrine_Search_TestCase ());
$search -> addTestCase ( new Doctrine_Search_Query_TestCase ());
$test -> addTestCase ( $search );
2006-12-28 00:20:26 +03:00
// Cache tests
2007-09-03 22:19:37 +04:00
$cache = new GroupTest ( 'Cache tests' );
$cache -> addTestCase ( new Doctrine_Query_Cache_TestCase ());
$cache -> addTestCase ( new Doctrine_Cache_Apc_TestCase ());
//$cache->addTestCase(new Doctrine_Cache_Memcache_TestCase());
//$cache->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
//$cache->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$cache->addTestCase(new Doctrine_Cache_FileTestCase());
//$cache->addTestCase(new Doctrine_Cache_SqliteTestCase());
//$cache->addTestCase(new Doctrine_Cache_TestCase());
$test -> addTestCase ( $cache );
2007-06-19 15:19:53 +04:00
2007-09-13 00:50:39 +04:00
$test -> addTestCase ( new Doctrine_Query_ApplyInheritance_TestCase ());
2007-04-08 18:55:14 +04:00
2007-09-19 20:26:28 +04:00
$test -> addTestCase ( new Doctrine_Migration_TestCase ());
2007-09-21 06:48:13 +04:00
$test -> addTestCase ( new Doctrine_Import_Schema_TestCase ());
$test -> addTestCase ( new Doctrine_Export_Schema_TestCase ());
2007-07-23 23:22:31 +04:00
class CliReporter extends HtmlReporter {
public function paintHeader (){
echo " Doctrine UnitTests \n " ;
echo " ==================== \n " ;
}
public function paintFooter (){
2007-07-29 00:28:20 +04:00
echo " \n " ;
2007-09-02 20:19:32 +04:00
foreach ( $this -> _test -> getMessages () as $message ) {
print $message . " \n " ;
}
2007-07-23 23:22:31 +04:00
echo " ==================== \n " ;
print " Tested: " . $this -> _test -> getTestCaseCount () . ' test cases' . " \n " ;
print " Successes: " . $this -> _test -> getPassCount () . " passes. \n " ;
print " Failures: " . $this -> _test -> getFailCount () . " fails. \n " ;
}
}
2006-10-01 17:54:15 +04:00
class MyReporter extends HtmlReporter {
2007-07-23 23:22:31 +04:00
public function paintHeader () {
2007-09-03 00:59:39 +04:00
?>
2007-07-23 23:22:31 +04:00
< html >
< head >
< title > Doctrine Unit Tests </ title >
< style >
. fail { color : red ; } pre { background - color : lightgray ; }
</ style >
</ head >
< body >
< h1 > Doctrine Unit Tests </ h1 >
< ? php
}
2006-10-01 17:54:15 +04:00
public function paintFooter ()
{
2007-07-23 23:22:31 +04:00
2007-09-03 02:34:02 +04:00
print '<pre>' ;
2007-09-02 20:19:32 +04:00
foreach ( $this -> _test -> getMessages () as $message ) {
2007-09-05 23:02:41 +04:00
print " <p> $message </p> " ;
2007-09-02 20:19:32 +04:00
}
2007-09-03 02:34:02 +04:00
print '</pre>' ;
$colour = ( $this -> _test -> getFailCount () > 0 ? 'red' : 'green' );
print '<div style=\'' ;
2007-09-04 17:22:38 +04:00
print " padding: 8px; margin-top: 1em; background-color: $colour ; color: white; " ;
2007-09-03 02:34:02 +04:00
print '\'>' ;
2007-09-04 17:19:42 +04:00
print $this -> _test -> getTestCaseCount () . ' test cases.' ;
2007-09-03 02:34:02 +04:00
print '<strong>' . $this -> _test -> getPassCount () . '</strong> passes and ' ;
print '<strong>' . $this -> _test -> getFailCount () . '</strong> fails.' ;
print '</div>' ;
2006-10-01 17:54:15 +04:00
}
}
?>
2007-06-01 14:17:50 +04:00
< ? php
2007-09-03 02:34:02 +04:00
if ( PHP_SAPI === 'cli' ) {
2007-07-23 23:22:31 +04:00
$reporter = new CliReporter ();
2007-09-05 23:02:41 +04:00
$argv = $_SERVER [ 'argv' ];
array_shift ( $argv );
$options = parseOptions ( $argv );
2007-09-02 18:24:49 +04:00
} else {
2007-09-05 23:02:41 +04:00
$options = $_GET ;
2007-09-03 00:59:39 +04:00
$reporter = new MyReporter ();
2007-07-23 23:22:31 +04:00
}
2007-07-06 16:37:02 +04:00
2007-09-02 22:08:13 +04:00
2007-09-03 19:18:12 +04:00
if ( isset ( $options [ 'group' ])) {
2007-09-03 02:34:02 +04:00
$testGroup = new GroupTest ( 'Custom' );
foreach ( $options [ 'group' ] as $group ) {
2007-09-03 19:18:12 +04:00
if ( ! isset ( $$group )) {
2007-09-03 00:59:39 +04:00
if ( class_exists ( $group )) {
$testGroup -> addTestCase ( new $group );
}
2007-09-03 00:12:45 +04:00
die ( $group . " is not a valid group of tests \n " );
}
2007-09-02 22:08:13 +04:00
$testGroup -> addTestCase ( $$group );
2007-09-03 00:59:39 +04:00
}
} else {
$testGroup = $test ;
}
2007-09-03 02:34:02 +04:00
$filter = '' ;
if ( isset ( $options [ 'filter' ])) {
$filter = $options [ 'filter' ];
2007-09-03 01:51:04 +04:00
}
2007-09-03 02:34:02 +04:00
if ( isset ( $options [ 'help' ])) {
2007-09-03 01:59:48 +04:00
echo " Doctrine test runner help \n " ;
echo " =========================== \n " ;
echo " To run all tests simply run this script without arguments. \n " ;
echo " \n Flags: \n " ;
echo " -coverage will generate coverage report data that can be viewed with the cc.php script in this folder. NB! This takes time. You need xdebug to run this \n " ;
2007-09-03 22:19:37 +04:00
echo " -group <groupName1> <groupName2> <className1> Use this option to run just a group of tests or tests with a given classname. Groups are currently defined as the variable name they are called in this script. \n " ;
echo " -filter <string1> <string2> case insensitive strings that will be applied to the className of the tests. A test_classname must contain all of these strings to be run \n " ;
echo " \n Available groups: \n tickets, transaction, driver, data_dict, sequence, export, import, expression, core, relation, data_types, utility, db, event_listener, query_tests, record, cache \n " ;
2007-09-03 01:59:48 +04:00
die ();
}
2007-09-03 02:34:02 +04:00
if ( isset ( $options [ 'coverage' ])) {
2007-08-11 17:30:14 +04:00
xdebug_start_code_coverage ( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
2007-09-03 01:51:04 +04:00
$testGroup -> run ( $reporter , $filter );
2007-09-03 02:34:02 +04:00
$result [ 'path' ] = Doctrine :: getPath () . DIRECTORY_SEPARATOR ;
$result [ 'coverage' ] = xdebug_get_code_coverage ();
2007-08-11 17:30:14 +04:00
xdebug_stop_code_coverage ();
2007-09-03 02:34:02 +04:00
file_put_contents ( 'coverage.txt' , serialize ( $result ));
2007-09-02 18:24:49 +04:00
} else {
2007-09-03 01:51:04 +04:00
$testGroup -> run ( $reporter , $filter );
2007-08-11 17:30:14 +04:00
}