Ejemplo n.º 1
0
 /**
  * Creates an instance of Broadcaster if not already created
  */
 private static function initializeBroadcaster()
 {
     if (is_null(self::$broadcaster)) {
         // Create new grader
         self::$broadcaster = new Broadcaster();
     }
 }
Ejemplo n.º 2
0
 /**
  * Answer a clarification
  * 
  * @param type $clarificationData
  * @param type $contestData
  * @param type $message
  */
 public static function answer($clarificationData, $contestData, $message = 'lol')
 {
     // Prepare request
     $r = new Request();
     $r["clarification_id"] = $clarificationData["response"]["clarification_id"];
     // Log in the user
     $r["auth_token"] = OmegaupTestCase::login($contestData["director"]);
     // Update answer
     $r["answer"] = $message;
     // Call api
     ClarificationController::apiUpdate($r);
 }
 public function testPublicClarificationsCanBeViewed()
 {
     // Get a problem
     $problemData = ProblemsFactory::createProblem();
     // Get a contest
     $contestData = ContestsFactory::createContest();
     // Add the problem to the contest
     ContestsFactory::addProblemToContest($problemData, $contestData);
     // Create our contestant who will submit the clarification
     $contestant = UserFactory::createUser();
     // Create our contestant who will try to view the clarification
     $contestant2 = UserFactory::createUser();
     // Create the clarification, note that contestant will create it
     $this->detourBroadcasterCalls();
     $clarificationData = ClarificationsFactory::createClarification($problemData, $contestData, $contestant);
     // Manually set the just created clarification to PUBLIC
     $clarification = ClarificationsDAO::getByPK($clarificationData['response']['clarification_id']);
     $clarification->setPublic('1');
     ClarificationsDAO::save($clarification);
     // Prepare the request object
     $r = new Request();
     $r['clarification_id'] = $clarificationData['response']['clarification_id'];
     // Log in with the author of the clarification
     $r['auth_token'] = $this->login($contestant2);
     // Call API
     $response = ClarificationController::apiDetails($r);
     // Check the data we got
     $this->assertClarification($r['clarification_id'], $response);
 }
Ejemplo n.º 4
0
 protected function detourBroadcasterCalls($times = null)
 {
     if (is_null($times)) {
         $times = $this->once();
     }
     $broadcasterMock = $this->getMock('Broadcaster', array('broadcastClarification'));
     $broadcasterMock->expects($times)->method('broadcastClarification');
     ClarificationController::$broadcaster = $broadcasterMock;
 }