function testLoanerModule()
 {
     //creates a new loaner to test
     $loaner1 = new Loaner("remote3", "remote", "available", null);
     //tests the getters
     $this->assertEqual($loaner1->get_id(), "remote3");
     $this->assertEqual($loaner1->get_status(), "available");
     $this->assertEqual($loaner1->get_type(), "remote");
     $this->assertEqual($loaner1->get_booking_id(), null);
     $this->assertTrue(insert_dbLoaners($loaner1));
     $this->assertTrue($loaner1 = $loaner1->check_out("11-01-01Meghan2077291234"));
     //ensures that the loaner was checked out successfully
     $this->assertTrue($loaner1->get_status() == "inuse");
     $this->assertEqual($loaner1->get_booking_id(), "11-01-01Meghan2077291234");
     //checks that a loaner cannot be checked out twice
     $this->assertFalse($loaner1->check_out("11-01-01Jones2077311154"));
     //checks in loaner
     $loaner1 = $loaner1->check_in("11-01-01Meghan2077291234");
     $this->assertEqual($loaner1->get_status(), "available");
     $this->assertEqual($loaner1->get_booking_id(), null);
     //        $this->assertTrue(delete_dbLoaners($loaner1));
     echo "testLoaner complete";
 }
 function testdbLoanersModule()
 {
     //creates some loaners to add to the database
     $loaner1 = new Loaner("remote3", "remote", "available", null);
     $loaner2 = new Loaner("remote4", "remote", "available", null);
     // tests the insert function
     $this->assertTrue(insert_dbLoaners($loaner1));
     $this->assertTrue(insert_dbLoaners($loaner2));
     //tests the retrieve function
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_id(), "remote3");
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_type(), "remote");
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_status(), "available");
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_booking_id(), null);
     //tests the update function
     $loaner1->check_out("11-02-07Meghan2077291234");
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_status(), "inuse");
     $this->assertEqual(retrieve_dbLoaners($loaner1->get_id())->get_booking_id(), "11-02-07Meghan2077291234");
     //tests the delete function
     $this->assertTrue(delete_dbLoaners($loaner1->get_id()));
     $this->assertTrue(delete_dbLoaners($loaner2->get_id()));
     $this->assertFalse(retrieve_dbLoaners($loaner2->get_id()));
     echo "testdbLoaners complete";
 }
/**
 * Updates a loaner in the dbLoaners table by deleting it and re-inserting it
 * @param $loaner the week to update
 */
function update_dbLoaners($loaner)
{
    if (!$loaner instanceof Loaner) {
        echo "Invalid argument for update_dbLoaners function call";
        return false;
    }
    if (delete_dbLoaners($loaner->get_id())) {
        return insert_dbLoaners($loaner);
    } else {
        echo mysql_error() . "unable to update dbLoaners table: " . $loaner->get_id();
        return false;
    }
}