Skip to content

Commit cd39963

Browse files
committed
Fix format of crawler constraints fail message
1 parent a014db1 commit cd39963

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Codeception/Constraint/Crawler.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
namespace Codeception\Constraint;
66

77
use Codeception\Exception\ElementNotFound;
8-
use Codeception\Lib\Console\Message;
98
use DOMElement;
109
use PHPUnit\Framework\ExpectationFailedException;
1110
use SebastianBergmann\Comparator\ComparisonFailure;
1211
use Symfony\Component\DomCrawler\Crawler as SymfonyDomCrawler;
1312

13+
use function rtrim;
14+
use function sprintf;
1415
use function strpos;
1516

1617
class Crawler extends Page
@@ -47,15 +48,13 @@ protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure
4748
throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
4849
}
4950

50-
$output = "Failed asserting that any element by '{$selector}'";
51+
$output = "Failed asserting that any element by '{$selector}' ";
5152
$output .= $this->uriMessage('on page');
52-
$output .= " ";
5353

5454
if ($nodes->count() < 10) {
5555
$output .= $this->nodesList($nodes);
5656
} else {
57-
$message = new Message("[total %s elements]");
58-
$output .= $message->with($nodes->count())->getMessage();
57+
$output = sprintf('%s [total %d elements]', rtrim($output, ' '), $nodes->count());
5958
}
6059
$output .= "\ncontains text '{$this->string}'";
6160

src/Codeception/Constraint/CrawlerNot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure
3333
);
3434
}
3535

36-
$output = "There was '{$selector}' element";
36+
$output = "There was '{$selector}' element ";
3737
$output .= $this->uriMessage('on page');
3838
$output .= $this->nodesList($nodes, $this->string);
3939
$output .= "\ncontaining '{$this->string}'";

0 commit comments

Comments
 (0)