function testdbCrewsModule() { $s1 = new Crew("13-10-20", "foodpantry", 3, null, "", ""); $this->assertTrue(insert_dbCrews($s1)); $this->assertEqual(select_dbCrews($s1->get_id())->get_date(), $s1->get_date()); $this->assertTrue(delete_dbCrews($s1->get_id())); $s2 = new Crew("13-10-21", "foodbank", 3, null, "", ""); $this->assertTrue(insert_dbCrews($s2)); $s2 = new Crew("13-10-21", "foodbank", 2, null, "", ""); $this->assertTrue(update_dbCrews($s2)); $this->assertTrue(delete_dbCrews($s2->get_id())); echo "testdbCrews complete"; }
/** * Updates a crew in the db by deleting it (if it exists) and then replacing it * @param $s the crew to update */ function update_dbCrews($s) { if (!$s instanceof Crew) { die("Invalid argument for dbCrews->replace_crew function call"); } delete_dbCrews($s->get_id()); insert_dbCrews($s); return true; }