Example #1
0
 public static function getTestAsString(\PHPUnit_Framework_SelfDescribing $testCase)
 {
     if ($testCase instanceof Descriptive) {
         return $testCase->toString();
     }
     if ($testCase instanceof \PHPUnit_Framework_TestCase) {
         $text = $testCase->getName();
         $text = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1 \\2', $text);
         $text = preg_replace('/([a-z\\d])([A-Z])/', '\\1 \\2', $text);
         $text = preg_replace('/^test /', '', $text);
         $text = ucfirst(strtolower($text));
         $text = str_replace(['::', 'with data set'], [':', '|'], $text);
         return ReflectionHelper::getClassShortName($testCase) . ': ' . $text;
     }
     return $testCase->toString();
 }
Example #2
0
 public function toString()
 {
     return sprintf('%s: %s', ReflectionHelper::getClassShortName($this->getTestClass()), ucfirst($this->getFeature()));
 }
Example #3
0
 /**
  * Get the regex for matching the domain part of this route.
  *
  * @param \Illuminate\Routing\Route $route
  * @return string
  */
 private function getDomainRegex($route)
 {
     ReflectionHelper::invokePrivateMethod($route, 'compileRoute');
     $compiledRoute = ReflectionHelper::readPrivateProperty($route, 'compiled');
     return $compiledRoute->getHostRegex();
 }
Example #4
0
 private function addInternalDomain($route)
 {
     $regex = ReflectionHelper::readPrivateProperty($route, 'regex');
     $this->domainCollector[] = '/^' . $regex . '$/';
 }
Example #5
0
 private function addInternalDomain(Zend_Controller_Router_Route_Hostname $route)
 {
     $parts = ReflectionHelper::readPrivateProperty($route, '_parts');
     foreach ($parts as &$part) {
         if ($part === null) {
             $part = '[^.]+';
         }
     }
     $regex = implode('\\.', $parts);
     $this->domainCollector[] = '/^' . $regex . '$/iu';
 }
Example #6
0
 protected function clientRequest($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true)
 {
     if ($this instanceof Framework) {
         if (preg_match('#^(//|https?://(?!localhost))#', $uri)) {
             $hostname = parse_url($uri, PHP_URL_HOST);
             if (!$this->isInternalDomain($hostname)) {
                 throw new ExternalUrlException(get_class($this) . " can't open external URL: " . $uri);
             }
         }
         if ($method !== 'GET' && $content === null && !empty($parameters)) {
             $content = http_build_query($parameters);
         }
     }
     if (!ReflectionHelper::readPrivateProperty($this->client, 'followRedirects')) {
         $result = $this->client->request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
         $this->debugResponse($uri);
         return $result;
     } else {
         $maxRedirects = ReflectionHelper::readPrivateProperty($this->client, 'maxRedirects', 'Symfony\\Component\\BrowserKit\\Client');
         $this->client->followRedirects(false);
         $result = $this->client->request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
         $this->debugResponse($uri);
         return $this->redirectIfNecessary($result, $maxRedirects, 0);
     }
 }
Example #7
0
 /**
  * @return string
  */
 private function getApplicationDomainRegex()
 {
     $server = ReflectionHelper::readPrivateProperty($this->client, 'server');
     $domain = $server['HTTP_HOST'];
     return '/^' . str_replace('.', '\\.', $domain) . '$/';
 }
 protected function clientRequest($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true)
 {
     $this->debugSection("Request Headers", $this->headers);
     foreach ($this->headers as $header => $val) {
         // moved from REST module
         if (!$val) {
             continue;
         }
         $header = str_replace('-', '_', strtoupper($header));
         $server["HTTP_{$header}"] = $val;
         // Issue #827 - symfony foundation requires 'CONTENT_TYPE' without HTTP_
         if ($this instanceof Framework && $header === 'CONTENT_TYPE') {
             $server[$header] = $val;
         }
     }
     $server['REQUEST_TIME'] = time();
     $server['REQUEST_TIME_FLOAT'] = microtime(true);
     if ($this instanceof Framework) {
         if (preg_match('#^(//|https?://(?!localhost))#', $uri)) {
             $hostname = parse_url($uri, PHP_URL_HOST);
             if (!$this->isInternalDomain($hostname)) {
                 throw new ExternalUrlException(get_class($this) . " can't open external URL: " . $uri);
             }
         }
         if ($method !== 'GET' && $content === null && !empty($parameters)) {
             $content = http_build_query($parameters);
         }
     }
     if (!ReflectionHelper::readPrivateProperty($this->client, 'followRedirects')) {
         $result = $this->client->request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
         $this->debugResponse($uri);
         return $result;
     }
     $maxRedirects = ReflectionHelper::readPrivateProperty($this->client, 'maxRedirects', 'Symfony\\Component\\BrowserKit\\Client');
     $this->client->followRedirects(false);
     $result = $this->client->request($method, $uri, $parameters, $files, $server, $content, $changeHistory);
     $this->debugResponse($uri);
     return $this->redirectIfNecessary($result, $maxRedirects, 0);
 }
Example #9
0
 private function addInternalDomain(\Zend\Mvc\Router\Http\Hostname $route)
 {
     $regex = ReflectionHelper::readPrivateProperty($route, 'regex');
     $this->domainCollector[] = '/^' . $regex . '$/';
 }
Example #10
0
 /**
  * Returns a list of regex patterns for recognized domain names
  *
  * @return array
  */
 public function getInternalDomains()
 {
     $domains = [$this->getDomainRegex(Yii::app()->request->getHostInfo())];
     if (Yii::app()->urlManager->urlFormat === 'path') {
         $rules = ReflectionHelper::readPrivateProperty(Yii::app()->urlManager, '_rules');
         foreach ($rules as $rule) {
             if ($rule->hasHostInfo === true) {
                 $domains[] = $this->getDomainRegex($rule->template, $rule->params);
             }
         }
     }
     return array_unique($domains);
 }