Ejemplo n.º 1
0
 /**
  * Test "checkAndProcessSplits()" in Assignments.class.php.
  */
 public function testcheckAndProcessSplits()
 {
     // Add two splits.
     $my_array1['tSp_id'] = '1111';
     $my_array1['tSp_LessonName'] = 'split_1';
     $my_array1['tSp_gA'] = 'tG_1';
     $my_array1['tSp_PercentTime'] = '10';
     $this->assertTrue(count($my_array1) === 4);
     $my_array2['tSp_id'] = '1112';
     $my_array2['tSp_LessonName'] = 'split_2';
     $my_array2['tSp_gA'] = 'tG_2';
     $my_array2['tSp_PercentTime'] = '20';
     $this->assertTrue(count($my_array2) === 4);
     $split_instance = new SplitsClass();
     // Next insert into db.
     $split_instance->deleteRowId($my_array1['tSp_id']);
     $split_instance->insertRow($my_array1);
     $split_instance->deleteRowId($my_array2['tSp_id']);
     $split_instance->insertRow($my_array2);
     // Check to see if they exist.
     $row = $split_instance->getSplitByPrimaryKey($my_array1['tSp_id']);
     // Next check to see what is in $row.
     $this->assertTrue($row['tSp_id'] === '1111');
     // Note that id is a string.
     $row = $split_instance->getSplitByPrimaryKey($my_array2['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.
     echo "Splits not working.";
     // print_r( "Splits not working.\n");.
     $split_instance->deleteRowId($my_array1['tSp_id']);
     $split_instance->deleteRowId($my_array2['tSp_id']);
     $this->resetMyArray();
 }
Ejemplo n.º 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 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']);
 }