Skip to content

Commit 6ad43c7

Browse files
Merge branch '10.5' into 11.1
2 parents d26fb67 + 7a07c2f commit 6ad43c7

File tree

5 files changed

+113
-7
lines changed

5 files changed

+113
-7
lines changed

src/TextUI/Output/Printer/DefaultPrinter.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use function fopen;
1818
use function fsockopen;
1919
use function fwrite;
20-
use function sprintf;
2120
use function str_replace;
2221
use function str_starts_with;
2322
use PHPUnit\TextUI\DirectoryDoesNotExistException;
@@ -75,12 +74,7 @@ private function __construct(string $out)
7574
$tmp = explode(':', str_replace('socket://', '', $out));
7675

7776
if (count($tmp) !== 2) {
78-
throw new InvalidSocketException(
79-
sprintf(
80-
'"%s" does not match "socket://hostname:port" format',
81-
$out,
82-
),
83-
);
77+
throw new InvalidSocketException($out);
8478
}
8579

8680
$this->stream = fsockopen($tmp[0], (int) $tmp[1]);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Test runner emits warning when --log-junit is used with an invalid socket
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--log-junit';
8+
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
. 1 / 1 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
There was 1 PHPUnit test runner warning:
24+
25+
1) Cannot log test results in JUnit XML format to "socket://hostname:port:wrong": "socket://hostname:port:wrong" does not match "socket://hostname:port" format
26+
27+
WARNINGS!
28+
Tests: 1, Assertions: 1, Warnings: 1.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Test runner emits warning when --log-teamcity is used with an invalid socket
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--log-teamcity';
8+
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
. 1 / 1 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
There was 1 PHPUnit test runner warning:
24+
25+
1) Cannot log test results in TeamCity format to "socket://hostname:port:wrong": "socket://hostname:port:wrong" does not match "socket://hostname:port" format
26+
27+
WARNINGS!
28+
Tests: 1, Assertions: 1, Warnings: 1.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Test runner emits warning when --testdox-html is used with an invalid socket
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--testdox-html';
8+
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
. 1 / 1 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
There was 1 PHPUnit test runner warning:
24+
25+
1) Cannot log test results in TestDox HTML format to "socket://hostname:port:wrong": "socket://hostname:port:wrong" does not match "socket://hostname:port" format
26+
27+
WARNINGS!
28+
Tests: 1, Assertions: 1, Warnings: 1.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Test runner emits warning when --testdox-text is used with an invalid socket
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--testdox-text';
8+
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
9+
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14+
--EXPECTF--
15+
PHPUnit %s by Sebastian Bergmann and contributors.
16+
17+
Runtime: %s
18+
19+
. 1 / 1 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
There was 1 PHPUnit test runner warning:
24+
25+
1) Cannot log test results in TestDox plain text format to "socket://hostname:port:wrong": "socket://hostname:port:wrong" does not match "socket://hostname:port" format
26+
27+
WARNINGS!
28+
Tests: 1, Assertions: 1, Warnings: 1.

0 commit comments

Comments
 (0)