コード例 #1
0
ファイル: AssignmentsTest.php プロジェクト: thornview/tutorW
 /**
  * Test test "normalizePercentTimeTo100Percent()" in Assignments.class.inc
  *
  * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element
  * and to provide some background information or textual references.
  *
  * @return void
  */
 public function testrepairRowIfStartRecIslargerThanStopRec()
 {
     // First step is to place a distinct -correct lesson- in the database
     // and retrieve it and run a test.
     $this->testbuildArray();
     // Reset myArray to origninal values.
     $classInstance = new tutor\src\classes\AssignmentsClass();
     $result = $classInstance->delRowsByStudentId($this->myArray['tA_S_ID']);
     // Insure no previous lessons for this student.
     $this->assertTrue($result === 0);
     // Only deletion if improper cleanup else where.
     // Create a new student with an assignment that has error in start and stop.
     $tempStudent = 'abcdefg';
     $this->myArray['tA_S_ID'] = $tempStudent;
     $tempStartRec = '4';
     $tempStopRec = '2';
     $this->myArray['tA_StartRec'] = $tempStartRec;
     $this->myArray['tA_StopRec'] = $tempStopRec;
     $result = $classInstance->insertRecord($this->myArray);
     // Returns TRUE for success or FALSE for failure.  Inserts a lesson.
     $this->assertTrue($result === 1);
     // The test record was added to the DB.
     $result = $classInstance->repairRowIfStartRecIsLargerThanStopRec($tempStudent, $this->myArray['tG_AssignmentName'], $tempStartRec);
     $this->assertTrue(is_array($result));
     $this->assertTrue($result['tA_StartRecWasGreater'] === TRUE);
     $this->assertTrue($result['tA_subsequentAssignmentInserted'] === TRUE);
     $this->assertTrue($result['tA_ErroneousAssignmentDeleted'] === TRUE);
     $result = $classInstance->delRowsByStudentId($tempStudent);
     // Insure no previous lessons for this student.
     $message = __LINE__ . ' Row should have been previously deleted.';
     $this->assertEquals($result, TRUE, $message);
     // Now test for call with no error in start and stop.
     $tempStartRec = '2';
     $tempStopRec = '4';
     $this->myArray['tA_StartRec'] = $tempStartRec;
     $this->myArray['tA_StartRec'] = $tempStartRec;
     $result = $classInstance->insertRecord($this->myArray);
     $this->assertTrue($result === 1);
     $result = $classInstance->repairRowIfStartRecIsLargerThanStopRec($tempStudent, $this->myArray['tG_AssignmentName'], $tempStartRec);
     $this->assertTrue(is_array($result));
     $this->assertTrue(count($result) === 1);
     $this->assertTrue($result['tA_StartRecWasGreater'] === FALSE);
     // Clean up.
     $classInstance->delRowsByStudentId($tempStudent);
     unset($result);
     $this->testbuildArray();
     // Reset myArray to origninal values.
     $classInstance->delRowsByStudentId($this->myArray['tA_S_ID']);
     $classInstance->delRowsByStudentId('abcdefg');
     unset($classInstance);
 }