Php 检查我是否停留在同一页

Php 检查我是否停留在同一页,php,behat,mink,Php,Behat,Mink,我使用mink测试一个网站,我想编写一个测试场景来检查错误场景。所以我想看看我是否插入了无效数据,一个页面应该返回错误,我应该和以前在同一个页面上。我的意思是我不想再翻页了。 为此,我编写了一个测试场景,如下所示: some steps .... And Save current page some other steps.... Then I should stay in the same page 对于我在方法中编写的两个步骤,如下所示: /** * @Given /^Save curr

我使用mink测试一个网站,我想编写一个测试场景来检查错误场景。所以我想看看我是否插入了无效数据,一个页面应该返回错误,我应该和以前在同一个页面上。我的意思是我不想再翻页了。 为此,我编写了一个测试场景,如下所示:

some steps ....
And Save current page
some other steps....
Then I should stay in the same page
对于我在方法中编写的两个步骤,如下所示:

/**
 * @Given /^Save current page$/
 */
public function SaveCurrentPage() {
    $this->_last_page = $this->getSession ()->getCurrentUrl ();
}


但我真的不喜欢我的解决方案。因为保存当前页面这一行与应用程序的行为无关,只用于mink,我认为这不是behat/mink的目标。 有没有更好的解决办法

提前谢谢

在打开页面的步骤中存储最后访问的页面。谢谢@JakubZalas我真的不知道这会这么容易。谢谢,我还有一个问题。为了恢复上一步中的最后一页,我应该重新定义所有步骤,如“I go to”或“I follow to”。是这样吗?
/**
 * @Given /^I should stay in the same page$/
 */
public function StayInSamePage() {
    if ($this->_last_page === null) {
        throw new FailureException ( "current page is not defined" );
        // throw new Exception ( "current page is not defined" );
    }
    if ($this->_last_page !== $this->getSession ()->getCurrentUrl ()) {

        throw new FailureException ( "you should be in " . $this->_last_page . " but you are in  " . $this->getSession ()->getCurrentUrl () );
        // throw new Exception ( "you should be in " . $this->_last_page . " but you are in " . $this->getSession ()->getCurrentUrl () );
    } else {
        return;
    }
}