/** * @param Request $request * @param Element $config * @return boolean */ public function match(Request $request, Element $config) { if (!$config->getRequest()->hasBody()) { return true; } if (!$this->phpMatcher->match($request->getContent(), $config->getRequest()->getBody())) { return false; } return true; }
private function headersMatches(View $subject, $argument) { if (isset($argument['headers'])) { return $this->matcher->match($subject->getHeaders(), $argument['headers']); } return true; }
/** * @param Request $request * @param Element $config * @return boolean */ public function match(Request $request, Element $config) { if (!$config->getRequest()->hasBodyParameters() && !$config->getRequest()->hasQueryParameters()) { return true; } foreach ($config->getRequest()->getQueryParameters() as $name => $valuePattern) { if (!$request->query->has($name)) { return false; } if (!$this->phpMatcher->match($request->query->get($name), $valuePattern)) { return false; } } foreach ($config->getRequest()->getBodyParameters() as $name => $valuePattern) { if (!$request->request->has($name)) { return false; } if (!$this->phpMatcher->match($request->request->get($name), $valuePattern)) { return false; } } return true; }
/** * {@inheritdoc} */ public function diff($actual, $expected) { if (!$this->matcher->match($actual, $expected)) { return $this->matcher->getError(); } }
/** * @dataProvider expanderExamples() */ public function test_expanders($value, $pattern, $expectedResult) { $this->assertSame($expectedResult, $this->matcher->match($value, $pattern)); $this->assertSame($expectedResult, PHPMatcher::match($value, $pattern)); }
/** * @param mixed $value * * @return bool */ protected function matches($value) { return $this->matcher->match($value, $this->pattern); }
/** * @param string $name * @param mixed $subject * @param array $arguments * * @return FailureException */ protected function getNegativeFailureException($name, $subject, array $arguments) { return new FailureException($this->matcher->getError()); }
/** * @param PyStringNode $json * * @Then the response should contain: */ public function assertResponseContains(PyStringNode $json) { $this->matcher->match((string) $this->response->getBody(), $json->getRaw()); \PHPUnit_Framework_Assert::assertNull($this->matcher->getError()); }
function test_matcher_with_wildcard() { $this->assertTrue($this->matcher->match('test', '@*@')); $this->assertTrue($this->matcher->match('test', '@wildcard@')); }