我正在使用
PHPUnit并尝试检查页面上是否存在文本. assertRegExp工作但使用if语句我得到错误Failed断言null为真.
我知道$test返回null,但是如果文本存在,我不知道如何让它返回1或0或true / false?任何帮助表示感谢.
$element = $this->byCssSelector('body')->text(); $test = $this->assertRegExp('/find this text/i',$element); if($this->assertTrue($test)){ echo 'text found'; } else{ echo 'not found'; }
assertRegExp()将不返回任何内容.如果断言失败 – 意味着找不到文本 – 则以下代码将不会执行:
$this->assertRegExp('/find this text/i',$element); // following code will not get executed if the text was not found // and the test will get marked as "Failed"
原文地址:https://www.jb51.cc/regex/356876.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。