doubi6215 2019-02-22 14:36
浏览 26

登录用户进行电子邮件确认,Behat测试

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值