openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

test.php (1256B)


      1 <?php
      2 
      3 echo "<html><body>";
      4 
      5 ini_set('display_errors', 1);
      6 ini_set('html_errors', 0);
      7 error_reporting(E_ALL & ~E_NOTICE);
      8 
      9 require (__DIR__.'/../modules/autoload.php');
     10 
     11 $tests = [
     12 	new \util\text\variables\VariablesTest(),
     13 	new \util\test\YAMLTest(),
     14 	new \util\test\MustacheTest(),
     15 	new \security\test\PasswordTest(),
     16 	new \util\test\ClassNameTest(),
     17 	new \util\test\TextMessageTest(),
     18 ];
     19 
     20 echo '<h1>Running Tests</h1>';
     21 
     22 $success = 0;
     23 $failed  = 0;
     24 
     25 foreach( $tests as $test ) {
     26 	$class = new ReflectionClass($test);
     27 
     28 	echo '<h2>'.$class->getName().'</h2>';
     29 	$methods = $class->getMethods();
     30 	foreach( $methods as $method ) {
     31 		if   ( strstr($method->getName(),'test') ) {
     32 			echo '<h3>'.$method->getName().'</h3>';
     33 			try {
     34 				$method->invoke($test);
     35 				echo '<span style="color:green">OK</span>';
     36 				$success++;
     37 			}
     38 			catch( \Exception $e ) {
     39 				echo '<strong style="color:red">Test failed: '.$e->getMessage().'</strong>';
     40 				echo '<pre style="background-color:red">'.$e->getTraceAsString().'</pre>';
     41 				$failed++;
     42 			}
     43 		}
     44 	}
     45 
     46 
     47 }
     48 
     49 echo "<h1>Summary</h1>".($success+$failed).' Tests, '.$success.' success, '.$failed.' failed';
     50 
     51 echo '<p><strong>'.(($failed==0)?"ALL TESTS OK":"THERE ARE TEST FAILURES").'</strong></p>';
     52 
     53 echo "</body></html>";