Exemple #1
0
 /**
  * Run all test classes
  */
 function index()
 {
     if (hasPhpUnit()) {
         $tests = ClassInfo::subclassesFor('SapphireTest');
         array_shift($tests);
         $this->runTests($tests);
     } else {
         echo "Please install PHPUnit using pear";
     }
 }
Exemple #2
0
 function init()
 {
     parent::init();
     $canAccess = Director::isDev() || Director::is_cli() || Permission::check("ADMIN");
     if (!$canAccess) {
         return Security::permissionFailure($this);
     }
     if (!self::$default_reporter) {
         self::set_reporter(Director::is_cli() ? 'CliDebugView' : 'DebugView');
     }
     if (!hasPhpUnit()) {
         die("Please install PHPUnit using pear");
     }
 }
	function coverage() {
		if(hasPhpUnit()) {
			ManifestBuilder::load_all_classes();
			$tests = ClassInfo::subclassesFor('SapphireTest');
			array_shift($tests);
			unset($tests['FunctionalTest']);
		
			$this->runTests($tests, true);
		} else {
			echo "Please install PHPUnit using pear";
		}
	}
<?php
require_once 'TestRunner.php';
if(hasPhpUnit()) {
require_once 'PHPUnit/Framework.php';
}

/**
 * Test case class for the Sapphire framework.
 * Sapphire unit testing is based on PHPUnit, but provides a number of hooks into our data model that make it easier to work with.
 * 
 * @package sapphire
 * @subpackage testing
 */
class SapphireTest extends PHPUnit_Framework_TestCase {
	/**
	 * Path to fixture data for this test run.
	 * 
	 * @var string
	 */
	static $fixture_file = null;
	
	protected $originalMailer;
	protected $originalMemberPasswordValidator;
	protected $originalRequirements;
	protected $originalIsRunningTest;
	
	protected $mailer;
	
	protected static $is_running_test = false;
	
	public static function is_running_test() {