function testdbMasterScheduleModule() { //creates MasterScheduleEntries to insert to database $entry1 = new MasterScheduleEntry("house", "Wed", "odd", "1-5", 2, "", "I do not know what Lin means"); $entry2 = new MasterScheduleEntry("house", "Tue", "even", "1-5", 3, "", "Yay kitchen shift!"); $entry3 = new MasterScheduleEntry("house", "Wed", "even", "1-5", 2, "", ""); $entry4 = new MasterScheduleEntry("house", "Fri", "odd", "1-5", 4, "", "Best job ever."); //tests the insert function $this->assertTrue(insert_dbMasterSchedule($entry1)); $this->assertTrue(insert_dbMasterSchedule($entry2)); $this->assertTrue(insert_dbMasterSchedule($entry3)); $this->assertTrue(insert_dbMasterSchedule($entry4)); //tests the retrieve function $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_day(), $entry2->get_day()); $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_hours(), $entry2->get_hours()); $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_venue(), $entry2->get_venue()); $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_week_no(), $entry2->get_week_no()); $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_slots(), $entry2->get_slots()); $this->assertEqual(retrieve_dbMasterSchedule($entry2->get_id())->get_id(), $entry2->get_id()); //tests the update function $entry3->set_notes("This is a new note"); $this->assertTrue(update_dbMasterSchedule($entry3)); $this->assertEqual(retrieve_dbMasterSchedule($entry3->get_id())->get_notes(), "This is a new note"); //tests the delete function $this->assertTrue(delete_dbMasterSchedule($entry1->get_id())); $this->assertTrue(delete_dbMasterSchedule($entry2->get_id())); $this->assertTrue(delete_dbMasterSchedule($entry3->get_id())); $this->assertTrue(delete_dbMasterSchedule($entry4->get_id())); echo "testdbMasterSchedule complete"; }
function test_update_dbMasterSchedule() { $new_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", 14, 17, 2, "joe2071234567,sue2079876543", "This is a super fun shift.", "Afternoon Shift"); // not sure what the id looks like echo 'will test update_dbMasterSchedule </br>'; $new_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", 14, 17, 2, "joe2071234567,sue2079876543", "This is a super fun shift.", "Afternoon Shift"); // not sure what the id looks like echo 'will test update_dbMasterSchedule </br>'; error_log('testing update'); $result = insert_dbMasterSchedule($new_MasterScheduleEntry); echo 'result is ' . $result; if ($result) { echo "insert_dbMasterSchedule succeeded </br>"; } else { echo "insert_dbMasterSchedule failed</br>"; } // removed one person $updated_MasterScheduleEntry = new MasterScheduleEntry("monthly", "Wed", "odd", "14", "17", 2, "sue2079876543", "This is a super fun shift.", "Afternoon Shift"); // not sure what the id looks lik $mse = update_dbMasterSchedule($updated_MasterScheduleEntry); if ($mse == false) { echo 'update failed</br>'; } else { echo 'update succeeded'; } $res = delete_dbMasterSchedule($new_MasterScheduleEntry->get_MS_ID()); if ($res == null) { echo 'delete failed</br>'; } }