public function testCreateReservationFromWeekdaytoWeekday(){ $this->setSessionUserAdmin(); $startDate = '2011-11-14'; # A Monday $length = 1; $endDate = DBTestUtil::incrementDateBy($startDate, $length); $equipId = 1; $userComment = "test user comment"; $adminComment = "test admin comment"; $modStatus = RES_STATUS_PENDING; createReservation(getSessionVariable('user_id'), $equipId, $startDate, $length, $userComment, $adminComment, $modStatus); $actualReservation = mysql_fetch_assoc(doQuery("select * from ".getConfigVar('db_prefix')."_reservations ORDER BY res_id DESC LIMIT 1")); $this->assertEquals(getSessionVariable('user_id'), $actualReservation['user_id'], "User IDs not equal"); $this->assertEquals($equipId, $actualReservation['equip_id'], "Equip IDs not equal"); $this->assertEquals($startDate, $actualReservation['start_date'], "Start dates not equal"); $this->assertEquals($length, $actualReservation['length'], "Lengths not equal"); $this->assertEquals($endDate, $actualReservation['end_date'], "End dates not equal"); $this->assertEquals($userComment, $actualReservation['user_comment'], "User comments not equal"); $this->assertEquals($adminComment, $actualReservation['admin_comment'], "Admin comments not equal"); $this->assertEquals($modStatus, $actualReservation['mod_status'], "Statuses not equal"); }
public function testMyAccountPageForUserWithoutWarnings(){ $this->setSessionUserNormal(); require dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../src/myaccount.php'; $expectedPage = "<center><h3>My Account</h3></center> <table class=\"myaccount\"> <tr> <td colspan=4 class=\"header\">Edit User Information</td> </tr> <tr> <td class=\"centeredcellbold\">Username</td> <td colspan=3 class=\"centeredcell\">User</td> </tr> <tr> <td class=\"centeredcellbold\">Name</th> <td colspan=3 class=\"centeredcell\">Test User</td> </tr> <tr> <td class=\"centeredcellbold\">Change Password</td> <td class=\"centeredcellbold\">Current Password</td> <td class=\"centeredcellbold\">New Password</td> <td class=\"centeredcellbold\">Confirm Password</td> </tr> <tr> <form action=\"./index.php?pageid=savepassword\" method=\"POST\"><td class=\"centeredcellbold\"><input type=\"submit\" value=\"Save Password\"></td> <td class=\"centeredcell\"><input type=\"password\" name=\"curpass\"></td> <td class=\"centeredcell\"><input type=\"password\" name=\"newpass\"></th> <td class=\"centeredcell\"><input type=\"password\" name=\"confpass\"></td></form> </tr> <tr> <form action=\"./index.php?pageid=saveemail\" method=\"POST\"> <td colspan=1 class=\"centeredcellbold\">Email</th><td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"email\" size=30 value=\"".DBTestUtil::getTestEmail()."\"><input type=\"submit\" value=\"Save Email\"></td></form> </tr> <tr> <td colspan=1 class=\"centeredcellbold\">Warnings</th> <td class=\"centeredcellbold\" colspan=3><a href=\"./index.php?pageid=viewmywarnings\">1(3)</a></td> </tr> </table>"; $this->assertPageEquals($expectedPage, $pageData); }
public function testGetHomepage(){ $this->setSessionUserAdmin(); require dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../src/home.php'; $expectedPage = " <center> <h3>System Messages</h3> <div class=\"messageoutter\"><div class=\"priority2message\">This is a high priority message.</div></div> <div class=\"messageoutter\"><div class=\"priority1message\">This is a low priority message.</div></div> <h3>Office Hours</h3> <table class=\"pickuptimes\"> <tr> <td class=\"header\">Monday</td> <td class=\"header\">Tuesday</td> <td class=\"header\">Wednesday</td> <td class=\"header\">Thursday</td> <td class=\"header\">Friday</td> </tr> <tr> <td class=\"centeredcellbold\">3pm-5:30pm</td> <td class=\"centeredcellbold\">10am-12pm</td> <td class=\"centeredcellbold\">1pm-5:30pm</td> <td class=\"centeredcellbold\">8:30am-10am</td> <td class=\"centeredcellbold\">3pm-5pm</td> </tr> <tr> <td class=\"centeredcellbold\">-</td> <td class=\"centeredcellbold\">3:30pm-5:30pm</td> <td class=\"centeredcellbold\">-</td> <td class=\"centeredcellbold\">3:30pm-5:30pm</td> <td class=\"centeredcellbold\">-</td> </tr> </table> <h3>Your Equipment</h3> <table class=\"myequip\"> <tr> <td class=\"header\">Equipment Name</td> <td class=\"header\">Status</td> <td class=\"header\">Check-out Date</td> <td class=\"header\">Due Date</td> <td class=\"header\">-</td> </tr> <tr> <td class=\"myequipApproved\">All Users1</td> <td class=\"myequipApproved\">Approved</td> <td class=\"myequipApproved\">".DBTestUtil::decrementDateBy(DBTestUtil::getTestInitDate(), 10)."</td> <td class=\"myequipApproved\">".DBTestUtil::decrementDateBy(DBTestUtil::getTestInitDate(), 5)."</td> <td class=\"myequipApproved\"><a href=\"./index.php?pageid=viewreservation&resid=1\">View</a></td> </tr> <tr> <td class=\"myequipDenied\">All Users2</td> <td class=\"myequipDenied\">Denied</td> <td class=\"myequipDenied\">".DBTestUtil::decrementDateBy(DBTestUtil::getTestInitDate(), 12)."</td> <td class=\"myequipDenied\">".DBTestUtil::decrementDateBy(DBTestUtil::getTestInitDate(), 11)."</td> <td class=\"myequipDenied\"><a href=\"./index.php?pageid=viewreservation&resid=2\">View</a></td> </tr> </table> </center>"; $this->assertPageEquals($expectedPage, $pageData); }
public function testMakeReservationPageWithWarnedUser(){ $this->setSessionUserThreeWarnings(); $_GET['equipid'] = 1; $_GET['pageid'] = "reservation"; require dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../src/reservation.php'; $expectedPage = "<center><h3><font color=\"#FF0000\">Error: You have recieved 3 or more warnings.</font></h3>To reserve equipment please contact an admin: <br><br>Test Admin -- ".DBTestUtil::getTestEmail()."<br /></center>"; $this->assertPageEquals($expectedPage, $pageData); }
public static function tearDownAfterClass() { DBTestUtil::teardown(); session_destroy(); }
public static function setup(){ doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_users"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_equipment"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_reservations"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_messages"); DBTestUtil::addUsers(); DBTestUtil::addEquipment(); DBTestUtil::addReservations(); DBTestUtil::addMessages(); DBTestUtil::addWarnings(); }
public function testGetOurEquipForNormalUser(){ $this->setSessionUserNormal(); require dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../src/ourequip.php'; $expectedPage = "<center><h3>Our Equipment</h3></center> <center><b><a href=\"#Category 1\">Category 1</a> - <a href=\"#Category 2\">Category 2</a></b></center> <h3>Category 1</h3> <table class=\"ourequip\"> <tr> <td width=\"40%\" class=\"header\" id=\"Category 1\">Equipment Name</th> <td width=\"15%\" class=\"header\">--</th> <td width=\"25%\" class=\"header\">Status</th> <td width=\"20%\" class=\"header\">--</th> </tr> <tr> <td class=\"centeredcell\">All Users1</td> <td class=\"centeredcell\"><a href=\"./index.php?pageid=moreinfo&equipid=1\">More Info</a></td> <td class=\"centeredcell\">Available</td> <td class=\"centeredcell\"><a href=\"./index.php?pageid=reservation&equipid=1\">Reserve</a></td> </tr> </table> <h3>Category 2</h3> <table class=\"ourequip\"> <tr> <td width=\"40%\" class=\"header\" id=\"Category 2\">Equipment Name</th> <td width=\"15%\" class=\"header\">--</th> <td width=\"25%\" class=\"header\">Status</th> <td width=\"20%\" class=\"header\">--</th> </tr> <tr> <td class=\"centeredcell\">All Users2</td> <td class=\"centeredcell\"><a href=\"./index.php?pageid=moreinfo&equipid=2\">More Info</a></td> <td class=\"centeredcell\">Available</td> <td class=\"centeredcell\"><a href=\"./index.php?pageid=reservation&equipid=2\">Reserve</a></td> </tr> <tr> <td class=\"centeredcell\">Check Out From</td> <td class=\"centeredcell\"><a href=\"./index.php?pageid=moreinfo&equipid=4\">More Info</a></td> <td class=\"centeredcell\" colspan=2>Checkout from<br><a href=\"mailto:".DBTestUtil::getTestEmail()."\">Test Mod</a></td> </tr> </table>"; $this->assertPageEquals($expectedPage, $pageData); }