Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b4223d

Browse filesBrowse files
committed
Added a BC layer for older PHPUnit
1 parent 87aebab commit 8b4223d
Copy full SHA for 8b4223d

File tree

1 file changed

+22
-1
lines changed
Filter options

1 file changed

+22
-1
lines changed

‎src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ class CoverageListenerTrait
2525
{
2626
private $sutFqcnResolver;
2727
private $warningOnSutNotFound;
28+
private $warnings;
2829

2930
public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false)
3031
{
3132
$this->sutFqcnResolver = $sutFqcnResolver;
3233
$this->warningOnSutNotFound = $warningOnSutNotFound;
34+
$this->warnings = array();
3335
}
3436

3537
public function startTest($test)
@@ -47,7 +49,13 @@ public function startTest($test)
4749
$sutFqcn = $this->findSutFqcn($test);
4850
if (!$sutFqcn) {
4951
if ($this->warningOnSutNotFound) {
50-
$test->getTestResultObject()->addWarning($test, new Warning('Could not find the tested class.'), 0);
52+
$message = 'Could not find the tested class.';
53+
// addWarning does not exist on old PHPUnit version
54+
if (false && method_exists($test->getTestResultObject(), 'addWarning')) {
55+
$test->getTestResultObject()->addWarning($test, new Warning($message), 0);
56+
} else {
57+
$this->warnings[] = sprintf("%s::%s\n%s", get_class($test), $test->getName(), $message);
58+
}
5159
}
5260

5361
return;
@@ -89,4 +97,17 @@ private function findSutFqcn($test)
8997

9098
return $sutFqcn;
9199
}
100+
101+
public function __destruct()
102+
{
103+
if (!$this->warnings) {
104+
return;
105+
}
106+
107+
echo "\n";
108+
109+
foreach ($this->warnings as $key => $warning) {
110+
echo sprintf("%d) %s\n", ++$key, $warning);
111+
}
112+
}
92113
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.