<?php
$browser->check('/', 'テスト')->
with('response')->matches('/\w+の日記/u');
<?php
class myTesterResponse extends sfTesterResponse
{
public function contains($text)
{
$this->tester->like(
$this->getContent(),
'/' . preg_quote($text, '/') . '/u',
sprintf('response contains "%s"', mb_substr($text, 0, 40))
);
return $this->getObjectToReturn();
}
public function matches($regex)
{
if ($regex{0} == '!') {
$this->tester->unlike(
$this->getContent(),
mb_substr($regex, 1),
sprintf('response content does not match regex "%s"', mb_substr($regex, 1))
);
} else {
$this->tester->like(
$this->getContent(),
$regex,
sprintf('response content matches regex "%s"', $regex)
);
}
return $this->getObjectToReturn();
}
protected function getContent()
{
$charset = $this->response->getCharset();
$content = $this->response->getContent();
if ($charset !== null && strtolower($charset) !== 'utf-8') {
$content = mb_convert_encoding($content, 'UTF-8', $charset);
}
return $content;
}
}