I need to check if an email typed in is the same as the one that the user uses to log in, it is something like a password check on the website that checks for your password when you want to change some of the settings of your account. All of this happens on the same web form. the password, email and other changeable settings are on the same page. I need to write a test in order to verify the password and the email as the same of the user that has logged into the website. this testing is done in behat using the gherkin language. The problem i am facing is that i developed a code that helps me do this but it is giving the emails are valid even though they do not match. I am not sure if my code is right or if that is the right approach towards this problem or if it is some other issue. so any kind of email given is being accepted to be valid even though it is not of the user that is logged in. This is my FeatureContext.php file
/**
* @Then I need to check if :arg1 is same as currentmail
*/
public function iNeedToCheckIfIsSameAsCurrentmail($arg1)
{
$string = file_get_contents("http://somewebsite.prod.acquia-sites.com/users/user2");
$pattern = '/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/';
preg_match_all($pattern, $string, $email);
if($email===$arg1)
return true;
else
return false;
}
This is my feature file that is testing this functionality
Scenario Outline: This is to check the edit account page
Given I am on homepage
When I will login as <user>
When I click "My account"
Then I click "Edit"
Then I should see "ACCOUNT SETTINGS"
When I fill in "edit-mail" with "<mail>"
Then I need to check if "<mail>" is same as currentmail
Examples:
|user |mail |
|globaladmin |mno@asd.ca |
|Ed |jkl@asd.ca |
|Pub |ghi@asd.ca |
|CC |def@asd.ca |
|admin |abc@asd.ca |
I am poor with php at the moment and seeking help in order to figure this out. but any help would be appreciated. thank you in advance