Ejemplo n.º 1
0
 /**
  * Test select() method retrieves all _candidate and related info
  *
  * @return void
  * @covers Candidate::select
  * @covers Candidate::getData
  * @covers Candidate::getListOfTimePoints
  */
 public function testSelectRetrievesCandidateInfo()
 {
     $this->_setUpTestDoublesForSelectCandidate();
     $this->_candidate->select(969664);
     //validate _candidate Info
     $this->assertEquals($this->_candidateInfo, $this->_candidate->getData());
     //validate list of time points
     $expectedTimepoints = array();
     foreach ($this->_listOfTimePoints as $oneRow) {
         $expectedTimepoints[] = $oneRow['ID'];
     }
     $this->assertEquals($expectedTimepoints, $this->_candidate->getListOfTimePoints());
 }
Ejemplo n.º 2
0
    echo "Example: php delete_candidate 608858 SEA0252\n";
    die;
} else {
    $DCCID = $argv[1];
    $PSCID = $argv[2];
}
if ($DB->pselectOne("SELECT COUNT(*) FROM candidate WHERE CandID = :cid AND PSCID = :pid ", array('cid' => $DCCID, 'pid' => $PSCID)) == 0) {
    echo "The Candid : {$DCCID}  AND PSCID : {$PSCID} Doesn't Exist in " . "the database\n";
    die;
}
//Find candidate...
$candidate = new Candidate();
$candidate->select($DCCID);
//find the candidate with the given DCCID
//find sessions
$sessions = $candidate->getListOfTimePoints();
if (is_null($sessions) || empty($sessions)) {
    echo "There are no coressponding session for Candid : {$DCCID} \n";
    die;
}
echo "Dropping all DB entries for candidate DCCID: " . $DCCID . "And PSCID:" . $PSCID . "\n";
//find the test_names and commentIDs
$query = "SELECT ID, Test_name, CommentID FROM flag WHERE SessionID in (" . implode(" , ", $sessions) . ")";
$instruments = $DB->pselect($query, array());
//delete the sessions
$DB->delete("session", array("CandID" => $DCCID));
//delete each instrument table entry
foreach ($instruments as $instrument) {
    //delete the entry from the instrument table
    $DB->delete($instrument['Test_name'], array("CommentID" => $instrument['CommentID']));
    //delete from flag