Пример #1
0
 protected function uriMessage($onPage = "")
 {
     if (!$this->uri) {
         return "";
     }
     $message = new Message($this->uri);
     $message->style('bold');
     $message->prepend(" {$onPage} ");
     return $message;
 }
Пример #2
0
 protected function nodesList($nodes, $contains = null)
 {
     $output = "";
     foreach ($nodes as $node) {
         if ($contains) {
             if (strpos($node->getText(), $contains) === false) {
                 continue;
             }
         }
         /** @var $node \WebDriverElement  **/
         $message = new Message("<%s> %s");
         $output .= $message->with($node->getTagName(), $node->getText())->style('info')->prepend("\n+ ");
     }
     return $output;
 }
Пример #3
0
 protected function fail($nodes, $selector, \PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
 {
     /** @var $nodes DomCrawler  **/
     if (!$nodes->count()) {
         throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
     }
     $output = "Failed asserting that any element by '{$selector}'";
     $output .= $this->uriMessage('on page');
     $output .= " ";
     if ($nodes->count() < 10) {
         $output .= $this->nodesList($nodes);
     } else {
         $message = new Message("[total %s elements]");
         $output .= $message->with($nodes->count())->style('debug')->getMessage();
     }
     $output .= "\ncontains text '{$this->string}'";
     throw new \PHPUnit_Framework_ExpectationFailedException($output, $comparisonFailure);
 }