WebTestCase('Change Details and Password'); } function testUserlogin() { global $user; // open website $this->get('http://' . BASE_URL); $this->assertText('Login'); $this->clickLink('Normal Login'); // Password Login $this->assertText('Pass Phrase:'); // correct password $this->setField('email', $user['1']['username']); $this->setField('pword', $user['1']['password']); $this->clickSubmit('Login'); $this->assertText('Logout', "Login failed - don't see logout button"); // Open Change Details page directly. "Edit" might be ambiguous $this->get('https://'.BASE_URL.'/account.php?id=13'); // Set everything to testvalues $this->setField('fname', 'change details test 1'); $this->setField('mname', 'change details test 2'); $this->setField('lname', 'change details test 3'); $this->setField('suffix', 'change details test 4'); $this->setField('day', '01'); $this->setField('month', '02'); $this->setField('year', '2003'); $this->setField('Q1', 'change details test 5'); $this->setField('A1', 'change details test 6'); $this->setField('Q2', 'change details test 7'); $this->setField('A2', 'change details test 8'); $this->setField('Q3', 'change details test 9'); $this->setField('A3', 'change details test 10'); $this->setField('Q4', 'change details test 11'); $this->setField('A4', 'change details test 12'); $this->setField('Q5', 'change details test 13'); $this->setField('A5', 'change details test 14'); $this->clickSubmit('Update'); $this->assertText('Your details have been updated with the database.', "Changing details to test dataset failed"); // Open Change Details page directly. "Edit" might be ambiguous $this->get('https://'.BASE_URL.'/account.php?id=13'); // Check if test values appear on page $this->assertField('fname', 'change details test 1', "Do not see test entry 1"); $this->assertField('mname', 'change details test 2', "Do not see test entry 2"); $this->assertField('lname', 'change details test 3', "Do not see test entry 3"); $this->assertField('suffix', 'change details test 4', "Do not see test entry 4"); $this->assertField('Q1', 'change details test 5', "Do not see test entry 5"); $this->assertField('A1', 'change details test 6', "Do not see test entry 6"); $this->assertField('Q2', 'change details test 7', "Do not see test entry 7"); $this->assertField('A2', 'change details test 8', "Do not see test entry 8"); $this->assertField('Q3', 'change details test 9', "Do not see test entry 9"); $this->assertField('A3', 'change details test 10', "Do not see test entry 10"); $this->assertField('Q4', 'change details test 11', "Do not see test entry 11"); $this->assertField('A4', 'change details test 12', "Do not see test entry 12"); $this->assertField('Q5', 'change details test 13', "Do not see test entry 13"); $this->assertField('A5', 'change details test 14', "Do not see test entry 14"); // change everything back $this->setField('fname', $user['1']['details']['fname']); $this->setField('mname', $user['1']['details']['mname']); $this->setField('lname', $user['1']['details']['lname']); $this->setField('suffix', $user['1']['details']['suffix']); $this->setField('day', $user['1']['dob']['day']); $this->setField('month', $user['1']['dob']['month']); $this->setField('year', $user['1']['dob']['year']); $this->setField('Q1', $user['1']['lostpw']['questions']['1']); $this->setField('A1', $user['1']['lostpw']['answers']['1']); $this->setField('Q2', $user['1']['lostpw']['questions']['2']); $this->setField('A2', $user['1']['lostpw']['answers']['2']); $this->setField('Q3', $user['1']['lostpw']['questions']['3']); $this->setField('A3', $user['1']['lostpw']['answers']['3']); $this->setField('Q4', $user['1']['lostpw']['questions']['4']); $this->setField('A4', $user['1']['lostpw']['answers']['4']); $this->setField('Q5', $user['1']['lostpw']['questions']['5']); $this->setField('A5', $user['1']['lostpw']['answers']['5']); $this->clickSubmit('Update'); $this->assertText('Your details have been updated with the database.', "Changing details to test dataset failed"); // Maybe we should verify if changing back worked. Anyone? Alternatively use another // User for these tests and just update a timestamp in each entry. // Use the change password option to set a new password $this->clickLink('Change Password'); $this->setField('oldpassword', $user['1']['details']['password']); // What is the site doing with bad passwords which are very short $this->setField('pword1', "abcde"); $this->setField('pword2', "abcde"); $this->clickSubmit('Update Pass Phrase'); $this->assertText('Pass Phrase you submitted was too short.', "Site did not reject my short password."); // Use the change password option to set a new password $this->clickLink('Change Password'); $this->setField('oldpassword', $user['1']['details']['password']); // What is the site doing with bad passwords with only small letters $this->setField('pword1', "abcdefghi"); $this->setField('pword2', "abcdefghi"); $this->clickSubmit('Update Pass Phrase'); $this->assertText('failed to contain enough differing characters', "Site did not reject my very simple password."); // Use the change password option to set a new password (actually keep the same) $this->clickLink('Change Password'); $this->setField('oldpassword', $user['1']['password']); $this->setField('pword1', $user['1']['password']); $this->setField('pword2', $user['1']['password']); $this->clickSubmit('Update Pass Phrase'); $this->assertText('has been updated and your primary email', "I set a new very good password but it was not accepted for some reason."); // logout again $this->clickLink('Logout'); // Logout $this->assertText('Login', "Logout faild - don't see login button"); } } ?>