示例#1
0
 /**
  * Test method for delete().
  */
 public function testDelete()
 {
     // Test for id not available
     $workshift = new Workshift();
     $workshift->setWorkshiftId(15);
     try {
         $workshift->delete();
         $this->fail("Non existing ID was not checked!");
     } catch (WorkshiftException $e) {
         $this->assertEquals(WorkshiftException::INVALID_ROW_COUNT, $e->getCode());
     }
     // Test for valid id
     $workshift = new Workshift();
     $workshift->setName("Delete Shift");
     $workshift->setHoursPerDay(7);
     $workshift->save();
     // Check the saving
     $id = $workshift->getWorkshiftId();
     $updatedRow = $this->_getWorkshift($id);
     $this->assertNotNull($updatedRow);
     // check whether the ID exists
     $workshift->delete();
     $id = $workshift->getWorkshiftId();
     $updatedRow = $this->_getWorkshift($id);
     $this->assertNull($updatedRow);
     // Empty id
     $workshift = new Workshift();
     try {
         $workshift->delete();
         $this->fail("Empty ID was not checked!");
     } catch (WorkshiftException $e) {
         $this->assertEquals(WorkshiftException::INVALID_ID, $e->getCode());
     }
     // Invalid id
     $workshift = new Workshift();
     $workshift->setWorkshiftId("'fgW");
     try {
         $workshift->delete();
         $this->fail("Invalid ID was not checked!");
     } catch (WorkshiftException $e) {
         $this->assertEquals(WorkshiftException::INVALID_ID, $e->getCode());
     }
 }