Esempio n. 1
0
 public function test_break_user()
 {
     $this->setExpectedException("Exception", "Cannot validate changes to this correction: no valid user provided");
     $Correction = new Correction();
     $Correction->text = "adfaf";
     $Correction->setObject(new LocoClass());
     $Correction->commit();
 }
Esempio n. 2
0
 /**
  * Save a correction for this loco
  * @since Version 3.2
  * @param string $text
  * @param int $userId
  */
 public function newCorrection($text = false, $userId = false)
 {
     $Correction = new Correction();
     $Correction->text = $text;
     $Correction->setUser(UserFactory::CreateUser($userId));
     $Correction->setObject($this);
     $Correction->commit();
     return true;
 }
Esempio n. 3
0
 /**
  * @depends testAddLocoClass
  * @depends testAddLoco
  * @depends test_addUser
  */
 public function test_addClassCorrection($class_id, $loco_id, $User)
 {
     $Class = LocosFactory::CreateLocoClass($class_id);
     $Loco = LocosFactory::CreateLocomotive($loco_id);
     $Correction = new Correction();
     $Correction->text = "test class 123132";
     $Correction->setUser($User);
     $Correction->setObject($Class);
     $Correction->commit()->setMaintainer($User)->approve("Accepted");
     $Correction = new Correction();
     $Correction->text = "test class 1zzz";
     $Correction->setUser($User);
     $Correction->setObject($Class);
     $Correction->commit()->setMaintainer($User)->reject("blah test");
     $Correction = new Correction($Correction->id);
     $Correction = new Correction();
     $Correction->text = "test loco 123132";
     $Correction->setUser($User);
     $Correction->setObject($Loco);
     $Correction->commit()->setMaintainer($User)->approve("Accepted");
     $Correction = new Correction();
     $Correction->text = "test loco 1zzz";
     $Correction->setUser($User);
     $Correction->setObject($Loco);
     $Correction->commit()->setMaintainer($User)->reject("blah test");
     // break some stuff
     $Database = $Correction->getDatabaseConnection();
     $data = ["loco_id" => NULL, "class_id" => NULL];
     $where = ["correction_id = ?" => $Correction->id];
     $Database->update("loco_unit_corrections", $data, $where);
     $this->setExpectedException("Exception", "Unable to determine if this correction belongs to a locomotive or a locomotive class");
     $Correction = new Correction($Correction->id);
 }