public static function run()
 {
     $class = get_called_class();
     TEST($class, "{$class}.student.saveEditSubmitAndDelete", function ($class) {
         // Create job
         global $MJob;
         $jobId = new MongoId($MJob->save([], false));
         $studentId = new MongoId();
         // make sure saving an application for a job with no application
         // fails
         EQ(null, ApplicationStudent::save($jobId, $studentId, []));
         // create application for job
         $questionId = new MongoId();
         $questions = [$questionId];
         ApplicationJob::createOrUpdate($jobId, $questions);
         $answers = [['_id' => $questionId, 'answer' => 'swag']];
         $firstApplication = ApplicationStudent::save($jobId, $studentId, $answers);
         NEQ(null, $firstApplication);
         $applicationId = $firstApplication->getId();
         NEQ(null, $firstApplication->getQuestions());
         EQ('swag', $firstApplication->getQuestions()[0]['answer']);
         // edit application
         ApplicationStudent::edit($applicationId, [['_id' => $questionId, 'answer' => 'qswag']]);
         $editedApplication = ApplicationModel::getSavedForJob($jobId)[0];
         EQ('qswag', $editedApplication['questions'][0]['answer']);
         // submit application
         TRUE(ApplicationStudent::submitSaved($applicationId));
         TRUE(ApplicationModel::checkSubmitted($applicationId));
         // submit new application
         $secondStudent = new MongoId();
         $secondApplication = ApplicationStudent::submitNew($jobId, $secondStudent, $answers);
         TRUE(ApplicationModel::checkSubmitted($secondApplication->getId()));
         // create, save, and delete application
         $thirdStudent = new MongoId();
         $applicationToDelete = ApplicationStudent::save($jobId, $thirdStudent, $answers)->getId();
         TRUE(ApplicationModel::applicationExists($jobId, $thirdStudent));
         TRUE(ApplicationStudent::deleteSaved($applicationToDelete));
     });
     TEST($class, "{$class}.student.getUnclaimedAndClaimed", function ($class) {
         TRUE(false, 'TODO: Write test');
     });
     TEST($class, "{$class}.job.createOrUpdate", function ($class) {
         // Try to create/update application for nonexistent job
         FALSE(ApplicationJob::createOrUpdate(new MongoId(), []));
         // Create job
         global $MJob;
         $jobId = new MongoId($MJob->save([], false));
         // Try to create application for job
         $oldQuestionId = new MongoId();
         $oldQuestions = [$oldQuestionId];
         TRUE(ApplicationJob::createOrUpdate($jobId, $oldQuestions));
         EQ($MJob::getApplicationQuestionIds($jobId), $oldQuestions);
         // Try to change one question in application for job
         $newQuestionId = new MongoId();
         $newQuestions = [$newQuestionId];
         TRUE(ApplicationJob::createOrUpdate($jobId, $newQuestions));
         EQ($MJob::getApplicationQuestionIds($jobId), $newQuestions);
         TRUE(false, 'TODO: Check to make sure student applications are updated right.');
     });
 }
 public static function run()
 {
     $class = get_called_class();
     TEST($class, "{$class}.correctCollection", function () {
         $actualCollection = StudentModel::myCollection();
         $correctCollection = 'emails';
         EQ($actualCollection, $correctCollection, "Collection name invalid: {$actualCollection}");
     });
     TEST($class, "{$class}.save", function () {
         $id = self::$MStudentTest->save(array());
         TRUE(self::$MStudentTest->exists($id));
     });
 }
 public static function run()
 {
     $class = get_called_class();
     TEST($class, "{$class}.construct", function ($class) {
         $data = ['education' => [['school' => 'Yale University', 'class' => '2017', 'degree' => 'BS', 'dates' => ['start' => strtotime('August 2013')]]], 'experience' => [['title' => 'Intern', 'company' => 'Random Company', 'dates' => ['start' => strtotime('March 2017')]]], 'extracurriculars' => [['title' => 'Captain', 'organization' => 'Random Club', 'dates' => ['start' => strtotime('April 2012')]]], 'awards' => [['name' => 'random award']], 'projects' => [['name' => 'Random Project']]];
         $studentId = new MongoId();
         $student = new StudentProfile($studentId, $data);
         EQ($studentId, $student->getStudentId());
         EQ(null, $student->getEducation(1));
         $education = $student->getEducation(0);
         $educationStart = $education['dates']['start']->toDateTime()->getTimeStamp();
         EQ(strtotime('August 2013'), $educationStart);
     });
 }
 public static function run()
 {
     $class = get_called_class();
     TEST($class, "{$class}.parseRawData", function ($class) {
         $data1 = array('_id' => new MongoId(), 'text' => 'randomtext', 'recruiter' => new MongoId(), 'uses' => array(new MongoId(), new MongoId()), 'vanilla' => true);
         $data2 = array('_id' => new MongoId(), 'text' => 'randomtext2', 'recruiter' => new MongoId(), 'uses' => array(new MongoId(), new MongoId()), 'vanilla' => false);
         $dataList = array($data1, $data2);
         $res = $class::callPrivateMethod('Question', 'parseRawData', $dataList);
         EQ(count($res), 2);
         $q1 = $res[0];
         $q2 = $res[1];
         EQ($q1->getData(), $data1);
         EQ($q2->getData(), $data2);
     });
     TEST($class, "{$class}.createVanilla", function () {
         $text = 'random text haha';
         $question = Question::createVanilla($text);
         EQ($text, $question->getText(), "Wrong text");
         EQ(null, $question->getRecruiter(), "Recruiter should be null");
         EQ(true, $question->getVanilla(), "Not vanilla");
         NEQ(null, $question->getId(), "_id not null");
         $vanillas = Question::getAllVanilla();
         EQ(count($vanillas), 1, "Wrong vanilla count");
         $question2 = $vanillas[0];
         EQ($question->getData(), $question2->getData(), "Data doesn't match");
     });
     TEST($class, "{$class}.createCustom", function () {
         $question = Question::createCustom('randomtext', new MongoId());
         $id = $question->getId();
         $vanillas = Question::getAllVanilla();
         EQ(count($vanillas), 0, "Wrong vanilla count");
         $res = Question::getById($id);
         NEQ($res, null);
     });
     TEST($class, "{$class}.searchCustom", function () {
         $text1 = 'Give an example of where you\'ve been able to use your ' . 'leadership skills.';
         $text2 = 'Where do you see yourself in five years?';
         $text3 = 'What are your salary expectations?';
         $text4 = 'What are your strengths and weaknesses?';
         $id = [Question::createCustom($text1, new MongoId())->getId(), Question::createCustom($text2, new MongoId())->getId(), Question::createCustom($text3, new MongoId())->getId(), Question::createCustom($text4, new MongoId())->getId()];
         $res = Question::searchCustom('example years salary strength');
         EQ(4, count($res));
         $res = Question::searchCustom('strengths and weaknesses skills');
         EQ($id[3], $res[0]->getId());
         $res = Question::searchCustom('leadership skills weaknesses');
         EQ($id[0], $res[0]->getId());
     });
 }