예제 #1
0
 /**
  * Test "checkAndProcessSplits()" 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 testcheckAndProcessSplits()
 {
     // Add two splits.
     $myArray1['tSp_id'] = '1111';
     $myArray1['tSp_LessonName'] = 'split_1';
     $myArray1['tSp_gA'] = 'tG_1';
     $myArray1['tSp_PercentTime'] = '10';
     $this->assertTrue(count($myArray1) === 4);
     $myArray2['tSp_id'] = '1112';
     $myArray2['tSp_LessonName'] = 'split_2';
     $myArray2['tSp_gA'] = 'tG_2';
     $myArray2['tSp_PercentTime'] = '20';
     $this->assertTrue(count($myArray2) === 4);
     $splitInstance = new tutor\src\classes\SplitsClass();
     // Next insert into db.
     $splitInstance->deleteRowId($myArray1['tSp_id']);
     $splitInstance->insertRow($myArray1);
     $splitInstance->deleteRowId($myArray2['tSp_id']);
     $splitInstance->insertRow($myArray2);
     // Check to see if they exist.
     $row = $splitInstance->getSplitByPrimaryKey($myArray1['tSp_id']);
     // Next check to see what is in $row.
     $this->assertTrue($row['tSp_id'] === '1111');
     // Note that id is a string.
     $row = $splitInstance->getSplitByPrimaryKey($myArray2['tSp_id']);
     // Next check to see what is in $row.
     $this->assertTrue($row['tSp_id'] === '1112');
     // Note that id is a string.
     // Clean up database.
     $splitInstance->deleteRowId($myArray1['tSp_id']);
     $splitInstance->deleteRowId($myArray2['tSp_id']);
 }
예제 #2
0
 function testdeleteRowId()
 {
     //  This should have no effect on the database and does not insert a row that is not removed.
     $result = $this->testbuildArray();
     // reset myArray to origninal values.
     $classInstance = new tutor\src\classes\SplitsClass();
     $this->assertTrue(isset($classInstance));
     $result = $classInstance->deleteSplitLessonName('split_name');
     $result = $classInstance->deleteRowId($this->myArray['tSp_id']);
     $this->assertTrue($result === false);
     // If true improper cleanup.
     $result = $classInstance->insertRow($this->myArray);
     // true on success.
     $this->assertTrue($result === 1);
     // 'tSp_id' is assigned with each entry.  Must retrieve.
     $LastDbEntryAsArray = $classInstance->getLastDbEntryAsArray();
     $result = $classInstance->deleteRowId($LastDbEntryAsArray['tSp_id']);
     $this->assertTrue($result === 1);
     // affected rows
     $result = $classInstance->insertRow($this->myArray);
     $result = $classInstance->deleteRowId('not a number');
     $this->assertTrue($result === false);
     // $id must be a number.
     $result = $classInstance->deleteRowId(null);
     $this->assertTrue($result === false);
     // $id must be a number.
     $result = $classInstance->insertRow($this->myArray);
     // true on success.
     $this->assertTrue($result === 1);
     $result = $classInstance->getLastDbEntryAsArray();
     // Now test for $result containing accurate data.
     $this->assertTrue($result['tSp_LessonName'] === 'telling_time');
     $result = $classInstance->deleteRowId($result['tSp_id']);
     $this->assertTrue($result === 1);
     // affected rows.
     // Clean Up
     $result = $classInstance->deleteSplitLessonName($this->myArray['tSp_LessonName']);
 }