Example #1
0
 protected function nodesList($nodes, $contains = null)
 {
     $output = "";
     foreach ($nodes as $node) {
         if ($contains && 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;
 }
Example #2
0
 protected function fail($nodes, $selector, \SebastianBergmann\Comparator\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);
 }