/**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $this->user = $this->createUser();
     $this->deleteArray[] = $this->contest = ContestEditor::create($userID = $this->user->userID, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     $this->deleteArray[] = $this->contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $this->user = $this->createUser();
     $this->deleteArray[] = $this->participant = ContestParticipantEditor::create($contestID = $this->contest->contestID, $userID = $this->user->userID, $groupID = 0, $state = 'accepted');
     $this->deleteArray[] = $this->solution = ContestSolutionEditor::create($contestID = $this->contest->contestID, $participantID = $this->participant->participantID, $message = __METHOD__ . ' message', $state = 'private');
 }
Ejemplo n.º 3
0
 /**
  * 
  */
 public function testCreate()
 {
     require_once WCF_DIR . 'lib/data/contest/crew/ContestCrew.class.php';
     // create group
     $this->deleteArray[] = $group = $this->createGroup(array(array('optionID' => ContestCrew::getOptionID(), 'optionValue' => true)));
     $this->deleteArray[] = $user = $this->createUser($group->groupID);
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $contest = ContestEditor::create($userID = $user->userID, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array(), $state = 'applied');
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = 0, $userID = $user->userID, $groupID = 0, $state = 'private');
 }
Ejemplo n.º 4
0
 public function testContestsCounter()
 {
     require_once WCF_DIR . 'lib/data/contest/class/ContestClassEditor.class.php';
     $this->deleteArray[] = $class = ContestClassEditor::create($title = __METHOD__ . ' title');
     $this->assertEquals($class->contests, 0);
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array(), $state = 'private', $classIDArray = array($class->classID));
     // increase
     $class = new ContestClass($class->classID);
     $this->assertEquals($class->contests, 1);
     // decrease
     $contest->delete();
     $class = new ContestClass($class->classID);
     $this->assertEquals($class->contests, 0);
 }
 public function testSolutionCounter()
 {
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/solution/rating/ContestSolutionRatingEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $solution = ContestSolutionEditor::create($contestID = $contest->contestID, $participantID = 0, $message = __METHOD__ . ' message', $state = 'accepted');
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $rating = ContestSolutionRatingEditor::create($solution->solutionID, $optionID = 0, $score = 3, $user->userID);
     // increase
     $solution = new ContestSolutionEditor($solution->solutionID);
     $this->assertEquals($solution->ratings, 1);
     // decrease
     $rating->delete();
     $solution = new ContestSolutionEditor($solution->solutionID);
     $this->assertEquals($solution->ratings, 0);
 }
Ejemplo n.º 6
0
 public function testCreate()
 {
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $participant = ContestParticipantEditor::create($contestID = $contest->contestID, $userID = $user->userID, $groupID = 0, $state = 'accepted');
     $this->deleteArray[] = $solution = ContestSolutionEditor::create($contestID = $contest->contestID, $participantID = $participant->participantID, $message = __METHOD__ . ' message', $state = 'private');
     // basic checks
     $this->assertType('ContestSolution', $solution);
     $this->assertGreaterThan(0, $solution->solutionID);
     // owner check
     $this->assertFalse($solution->isOwner());
     $this->setCurrentUser($user);
     $this->assertTrue($solution->isOwner());
     // solution owner should have task to publish his private solution
     require_once WCF_DIR . 'lib/data/contest/participant/todo/ContestParticipantTodoList.class.php';
     $todo = new ContestParticipantTodoList();
     $todo->sqlConditions .= 'contest_participant.contestID = ' . intval($contest->contestID);
     $todo->readObjects();
     $task = array_pop($todo->getObjects());
     $this->assertEquals($task->action, 'participant.solution.private');
 }
Ejemplo n.º 7
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $state = 'private';
     // save entry
     $entry = ContestEditor::create($this->userID, $this->groupID, $this->subject, $this->text, $this->getOptions(), $state, $this->classIDArray, $this->participants, $this->jurys, $this->prices, $this->sponsors, $this->attachmentListEditor);
     $this->saved();
     $contestID = $entry->contestID;
     if ($this->sponsortalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/sponsortalk/ContestSponsortalkEditor.class.php';
         $sponsortalk = ContestSponsortalkEditor::create($contestID, $this->sponsortalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->jurytalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/jurytalk/ContestJurytalkEditor.class.php';
         $jurytalk = ContestJurytalkEditor::create($contestID, $this->jurytalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->comment_trigger) {
         require_once WCF_DIR . 'lib/data/contest/comment/ContestCommentEditor.class.php';
         $comment = ContestCommentEditor::create($contestID, $this->comment_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     // save tags
     if (MODULE_TAGGING) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $entry->updateTags($tagArray);
         }
     }
     // forward
     HeaderUtil::redirect('index.php?page=Contest&contestID=' . $entry->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }