function testdbPersonsModule() { // creates an empty dbPersons table $this->assertTrue(create_dbPersons()); //creates some people to add to the database $person1 = new Person("Smith", "John", "123 College Street", "Brunswick", "ME", "04011", 2075551234, "", "*****@*****.**", "guest", "", "Jane Smith", "98-01-01", "parent", ""); $person2 = new Person("Jones", "Bob", "100 Union Street", "Bangor", "ME", "04401", 2075555678, null, "*****@*****.**", "guest", "", "Dan Jones", "95-07-15", "grandfather", ""); $person3 = new Person("Adams", "Will", "12 River Road", "Augusta", "ME", "04330", 207551212, 2075553434, "*****@*****.**", "socialworker", "", null, null, null, ""); $person4 = new Person("Williams", "Elizabeth", "50 Main Street", "Portland", "ME", "04110", 2075555432, null, "*****@*****.**", "volunteer", "", null, null, null, ""); $person5 = new Person("Roberts", "Jill", "200 Main Street", "Portland", "ME", "04110", 2075556666, 2075550000, "*****@*****.**", "manager", "", null, null, null, ""); // tests the insert function $this->assertTrue(insert_dbPersons($person1)); $this->assertTrue(insert_dbPersons($person2)); $this->assertTrue(insert_dbPersons($person3)); $this->assertTrue(insert_dbPersons($person4)); $this->assertTrue(insert_dbPersons($person5)); //tests the retrieve function $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_id(), "John2075551234"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_first_name(), "John"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_last_name(), "Smith"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_address(), "123 College Street"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_city(), "Brunswick"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_state(), "ME"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_zip(), "04011"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_phone1(), 2075551234); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_phone2(), null); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_email(), "*****@*****.**"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_patient_name(), "Jane Smith"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_patient_birthdate(), "98-01-01"); $this->assertEqual(retrieve_dbPersons($person1->get_id())->get_patient_relation(), "parent"); $this->assertTrue(retrieve_dbPersons($person1->get_id())->check_type("guest")); //tests the update function $person2->set_address("5 Maine Street"); $this->assertTrue(update_dbPersons($person2)); $this->assertEqual(retrieve_dbPersons($person2->get_id())->get_address(), "5 Maine Street"); $this->assertFalse(retrieve_dbPersons($person3->get_id())->check_type("guest")); $person3->add_type("guest"); $this->assertTrue(update_dbPersons($person3)); $p3 = retrieve_dbPersons($person3->get_id()); $a = $p3->get_type(); $this->assertTrue(retrieve_dbPersons($person3->get_id())->check_type("guest")); $this->assertTrue(retrieve_dbPersons($person3->get_id())->check_type("socialworker")); //tests the delete function $this->assertTrue(delete_dbPersons($person1->get_id())); $this->assertTrue(delete_dbPersons($person2->get_id())); $this->assertTrue(delete_dbPersons($person3->get_id())); $this->assertTrue(delete_dbPersons($person4->get_id())); $this->assertTrue(delete_dbPersons($person5->get_id())); $this->assertFalse(retrieve_dbPersons($person4->get_id())); echo "testdbPersons complete"; }
} echo "connected...<br />"; echo "database selected...<br />"; // setup all of the tables if (create_dbLoaners()) { echo "dbLoaners table initialized...<br />"; } if (create_dbRooms()) { echo "dbRooms table initialized...<br />"; } if (create_dbRoomLogs()) { echo "dbRoomLogs table initialized...<br />"; } if (create_dbBookings()) { echo "dbBookings table initialized...<br />"; } if (create_dbPersons()) { echo "dbPersons table initialized...<br />"; } if (create_dbLog()) { echo "dbLog table initialized...<br />"; } /* if (create_dbWeeks()) echo("dbWeeks table initialized...<br />"); */ echo "Installation of mysql tables complete.<br>"; echo " To prevent data loss, run this program only if you want to clear all the tables.</p>"; ?> </body> </html>