/** * Test test "normalizePercentTimeTo100Percent()" in Assignments.class.inc. */ public function testrepairRowIfStartRecIslargerThanStopRec() { // Problem with 2 // First step is to place a distinct -correct lesson- in the database // and retrieve it and run a test. $this->resetMyArray(); // Reset myArray to origninal values. $ac_class_instance = new AssignmentsClass(); $result = $ac_class_instance->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. $temp_student_id = 'abcdefg'; $this->myArray['tA_S_ID'] = $temp_student_id; $temp_start_rec = '4'; $temp_stop_rec = '2'; $this->myArray['tA_StartRec'] = $temp_start_rec; $this->myArray['tA_StopRec'] = $temp_stop_rec; $result = $ac_class_instance->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 = $ac_class_instance->repairRowIfStartRecIsLargerThanStopRec($temp_student_id, $this->myArray['tG_AssignmentName'], $temp_start_rec); $this->assertTrue(is_array($result)); $this->assertTrue($result['tA_StartRecWasGreater'] === TRUE); $this->assertTrue($result['tA_subsequentAssignmentInserted'] === TRUE); $this->assertTrue($result['tA_ErroneousAssignmentDeleted'] === TRUE); $result = $ac_class_instance->delRowsByStudentId($temp_student_id); // 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. $temp_start_rec = '2'; $temp_stop_rec = '4'; $this->myArray['tA_StartRec'] = $temp_start_rec; $this->myArray['tA_StartRec'] = $temp_start_rec; $result = $ac_class_instance->insertRecord($this->myArray); $this->assertTrue($result === 1); $result = $ac_class_instance->repairRowIfStartRecIsLargerThanStopRec($temp_student_id, $this->myArray['tG_AssignmentName'], $temp_start_rec); $this->assertTrue(is_array($result)); $this->assertTrue(count($result) === 1); $this->assertTrue($result['tA_StartRecWasGreater'] === FALSE); // Clean up. $ac_class_instance->delRowsByStudentId($temp_student_id); unset($result); $this->resetMyArray(); // Reset myArray to origninal values. $ac_class_instance->delRowsByStudentId($this->myArray['tA_S_ID']); $ac_class_instance->delRowsByStudentId('abcdefg'); unset($ac_class_instance); $this->resetMyArray(); }