isMatching() public static method

Compares using mask.
public static isMatching ( $pattern, $actual, $strict = FALSE ) : boolean
return boolean
Ejemplo n.º 1
1
 private function assessOutputMatch(Job $job, $content)
 {
     if (!Tester\Assert::isMatching($content, $job->getOutput())) {
         Dumper::saveOutput($job->getFile(), $job->getOutput(), '.actual');
         Dumper::saveOutput($job->getFile(), $content, '.expected');
         return array(Runner::FAILED, 'Failed: output should match ' . Dumper::toLine(rtrim($content)));
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string $destination fully qualified presenter name (module:module:presenter)
  * @param string $path
  * @param array $params provided to the presenter usually via URL
  * @param array $post provided to the presenter via POST
  *
  * @return \Nette\Application\Responses\RedirectResponse
  * @throws \Exception
  */
 protected function checkRedirect($destination, $path = '/', $params = [], $post = [])
 {
     /** @var \Nette\Application\Responses\RedirectResponse $response */
     $response = $this->check($destination, $params, $post);
     if (!$this->__testbench_exception) {
         Assert::same(200, $this->getReturnCode());
         Assert::type('Nette\\Application\\Responses\\RedirectResponse', $response);
         Assert::same(302, $response->getCode());
         if ($path) {
             if (!\Tester\Assert::isMatching("~^https?://test\\.bench{$path}(?(?=\\?).+)\$~", $response->getUrl())) {
                 $path = Dumper::color('yellow') . Dumper::toLine($path) . Dumper::color('white');
                 $url = Dumper::color('yellow') . Dumper::toLine($response->getUrl()) . Dumper::color('white');
                 $originalUrl = new \Nette\Http\Url($response->getUrl());
                 Assert::fail(str_repeat(' ', strlen($originalUrl->getHostUrl()) - 13) . "path {$path} doesn't match\n{$url}\nafter redirect");
             }
         }
     }
     return $response;
 }