Behat:让方法__toString()没有实现错误

I have php 5.6.14.

Writing context for behat tests I saw an error:error

/** @When /^I want to see JS alert$/ */
public function iExecuteJs() {
    $this->webDriver()->executeScript("jsAlert()");
        if ($this->webDriver()->switchTo()->alert()->getText().contains("js")){
            echo "test passed";
        };

}

What should I do with it?

Thanks

Finally, I changed the code like:

    $element = $this->webDriver()->switchTo()->alert()->getText();
        if ($element == "I am a JS Alert"){
           echo "correct js alert appeared";
        }