예제 #1
0
 /**
  *    Deletes the last row.
  */
 public function testeditRow()
 {
     // Insert a row.  Retrieve the row.
     // Modify the row.  Retrieve the row and compare.
     $this->BuildArray();
     // reset variables.
     $classInstance = new tutor\src\classes\GenericAClass();
     $this->assertTrue(isset($classInstance));
     $mylocalArray['tG_AssignmentName'] = 'Test';
     $mylocalArray['tG_FormName'] = '479gAST dummy_form.php';
     $this->myArray['tG_AssignmentName'] = 'xx';
     $result = $classInstance->deleteRowsNamed($mylocalArray['tG_AssignmentName']);
     $this->assertTrue($result === 0);
     // check for accidental spurious row.
     $result = $classInstance->insertRecord($this->myArray);
     $this->assertTrue($result === 1);
     $row = $classInstance->getLastDbEntryAsArray();
     $this->assertTrue($row['tG_AssignmentName'] === $this->myArray['tG_AssignmentName']);
     $mylocalArray['id'] = $row['id'];
     $result = $classInstance->editRow($mylocalArray);
     $logFile = fopen("/var/www/jimfuqua/tutor/logs/testeditRow", "w");
     $s = var_export($result, true);
     $string = '$result = ' . $s . "\n";
     fwrite($logFile, $string);
     $this->assertTrue($result === 1);
     // Now retrieve the row and check for updated fields.
     $row2 = $classInstance->getRowFromDbAsArrayById($row['id']);
     $this->assertTrue($row2['id'] === $row['id']);
     $this->assertFalse($row2['tG_AssignmentName'] === $this->myArray['tG_AssignmentName']);
     $this->assertTrue($row2['tG_AssignmentName'] === $mylocalArray['tG_AssignmentName']);
     // clean up.
     // delete the record that was added.
     $r = $classInstance->deleteRowsNamed("Test");
     $this->assertTrue($r === 1);
     $this->BuildArray();
     // reset variables.
 }