コード例 #1
0
ファイル: BodyMatchingPolicy.php プロジェクト: coduo/tutu
 /**
  * @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;
 }
コード例 #2
0
 private function headersMatches(View $subject, $argument)
 {
     if (isset($argument['headers'])) {
         return $this->matcher->match($subject->getHeaders(), $argument['headers']);
     }
     return true;
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function diff($actual, $expected)
 {
     if (!$this->matcher->match($actual, $expected)) {
         return $this->matcher->getError();
     }
 }
コード例 #5
0
ファイル: MatcherTest.php プロジェクト: coduo/php-matcher
 /**
  * @dataProvider expanderExamples()
  */
 public function test_expanders($value, $pattern, $expectedResult)
 {
     $this->assertSame($expectedResult, $this->matcher->match($value, $pattern));
     $this->assertSame($expectedResult, PHPMatcher::match($value, $pattern));
 }
コード例 #6
0
 /**
  * @param mixed $value
  *
  * @return bool
  */
 protected function matches($value)
 {
     return $this->matcher->match($value, $this->pattern);
 }
コード例 #7
0
 /**
  * @param string $name
  * @param mixed  $subject
  * @param array  $arguments
  *
  * @return FailureException
  */
 protected function getNegativeFailureException($name, $subject, array $arguments)
 {
     return new FailureException($this->matcher->getError());
 }
コード例 #8
0
ファイル: ApiContext.php プロジェクト: php-lug/lug
 /**
  * @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());
 }
コード例 #9
0
ファイル: MatcherTest.php プロジェクト: cordoval/php-matcher
 function test_matcher_with_wildcard()
 {
     $this->assertTrue($this->matcher->match('test', '@*@'));
     $this->assertTrue($this->matcher->match('test', '@wildcard@'));
 }