/**
  * Creates an instance of Grader if not already created
  */
 private static function initializeGrader()
 {
     if (is_null(self::$grader)) {
         // Create new grader
         self::$grader = new Grader();
     }
 }
示例#2
0
 /**
  * Detours the Grader calls.
  * Problem: Submiting a new run invokes the Grader::grade() function which makes 
  * a HTTP call to official grader using CURL. This call will fail if grader is
  * not turned on. We are not testing the Grader functionallity itself, we are
  * only validating that we populate the DB correctly and that we make a call
  * to the function Grader::grade(), without executing the contents.
  * 
  * Solution: We create a phpunit mock of the Grader class. We create a fake 
  * object Grader with the function grade() which will always return true
  * and expects to be excecuted once.	 
  *
  */
 public function detourGraderCalls($times = null)
 {
     if (is_null($times)) {
         $times = $this->once();
     }
     // Create a fake Grader object which will always return true (see
     // next line)
     $graderMock = $this->getMock('Grader', array('Grade'));
     // Set expectations:
     $graderMock->expects($times)->method('Grade')->will($this->returnValue(true));
     // Detour all Grader::grade() calls to our mock
     RunController::$grader = $graderMock;
     ProblemController::$grader = $graderMock;
 }