protected function uriMessage($onPage = "") { if (!$this->uri) { return ""; } $message = new Message($this->uri); $message->style('bold'); $message->prepend(" {$onPage} "); return $message; }
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; }
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); }
protected function writeFinishedTest(\PHPUnit_Framework_TestCase $test) { if ($this->isDetailed($test)) { return; } if ($this->output->isInteractive()) { $this->getTestMessage($test)->prepend("\r")->width($this->columns[0])->write(); return; } if ($this->message) { $this->message('')->width($this->columns[0] - $this->message->apply('strip_tags')->getLength())->write(); } }
protected function writeFinishedTest(\PHPUnit_Framework_TestCase $test) { if ($this->isDetailed($test)) { return; } $conditionalFails = ""; $numFails = count($this->fails); if ($numFails == 1) { $conditionalFails = "[F]"; } elseif ($numFails) { $conditionalFails = "{$numFails}x[F]"; } $conditionalLen = strlen($conditionalFails) + 1; $conditionalFails = "<error>{$conditionalFails}</error> "; if ($this->output->isInteractive()) { $msg = $this->getTestMessage($test)->prepend("\r"); $msg->width($this->columns[0] - $conditionalLen)->append($conditionalFails)->write(); return; } if ($this->message) { $this->message('')->width($this->columns[0] - $this->message->apply('strip_tags')->getLength() - $conditionalLen)->append($conditionalFails)->write(); } }
protected function writelnFinishedTest(TestEvent $event, Message $result) { $test = $event->getTest(); if ($this->isDetailed($test)) { return; } if ($this->output->isInteractive()) { $this->output->write("\r"); } $result->append(' ')->write(); $this->writeCurrentTest($test, false); $conditionalFails = ""; $numFails = count($this->fails); if ($numFails == 1) { $conditionalFails = "[F]"; } elseif ($numFails) { $conditionalFails = "{$numFails}x[F]"; } $conditionalFails = "<error>{$conditionalFails}</error> "; $this->message($conditionalFails)->write(); $time = $event->getTime(); if ($time) { $seconds = (int) ($milliseconds = (int) ($time * 100)) / 100; $time = $seconds % 60 . '.' . $milliseconds; $this->message($time)->prepend('(')->append('s)')->style('info')->write(); } $this->output->writeln(''); }
public function toString() { return $this->getSignature() . ': ' . Message::ucfirst($this->getFeature()); }
protected function writelnFinishedTest(TestEvent $event, Message $result) { $test = $event->getTest(); if ($this->isDetailed($test)) { return; } if ($this->output->isInteractive()) { $this->output->write("\r"); } $result->append(' ')->write(); $this->writeCurrentTest($test, false); $conditionalFails = ""; $numFails = count($this->fails); if ($numFails == 1) { $conditionalFails = "[F]"; } elseif ($numFails) { $conditionalFails = "{$numFails}x[F]"; } $conditionalFails = "<error>{$conditionalFails}</error> "; $this->message($conditionalFails)->write(); $this->writeTimeInformation($event); $this->output->writeln(''); }