for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Behapi\Context;
use InvalidArgumentException;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Coduo\PHPMatcher\Factory;
use Coduo\PHPMatcher\Factory\SimpleFactory;
use Behapi\Tools\HttpHistory;
class PhpMatcher implements Context
{
use ApiTrait;
/** @var Factory */
private $factory;
public function __construct(HttpHistory $history)
$this->history = $history;
$this->factory = new SimpleFactory;
}
/** @Then the response content should match: */
public function response_content_should_match(PyStringNode $pattern)
$matcher = $this->factory->createMatcher();
$content = (string) $this->getResponse()->getBody();
if ($matcher->match($content, $pattern->getRaw())) {
return;
throw new InvalidArgumentException($matcher->getError());
public function response_content_should_not_match(PyStringNode $pattern)
if (!$matcher->match($content, $pattern->getRaw())) {
throw new InvalidArgumentException(sprintf(
'The response matches with the pattern "%s"',
$pattern->getRaw()
));