Skip to content

Commit

Permalink
Merge branch '10.5' into 11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 30, 2024
2 parents d26fb67 + 7a07c2f commit 6ad43c7
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/TextUI/Output/Printer/DefaultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use function fopen;
use function fsockopen;
use function fwrite;
use function sprintf;
use function str_replace;
use function str_starts_with;
use PHPUnit\TextUI\DirectoryDoesNotExistException;
Expand Down Expand Up @@ -75,12 +74,7 @@ private function __construct(string $out)
$tmp = explode(':', str_replace('socket://', '', $out));

if (count($tmp) !== 2) {
throw new InvalidSocketException(
sprintf(
'"%s" does not match "socket://hostname:port" format',
$out,
),
);
throw new InvalidSocketException($out);
}

$this->stream = fsockopen($tmp[0], (int) $tmp[1]);
Expand Down
28 changes: 28 additions & 0 deletions tests/end-to-end/logging/log-junit-invalid-socket.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Test runner emits warning when --log-junit is used with an invalid socket
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--log-junit';
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

. 1 / 1 (100%)

Time: %s, Memory: %s

There was 1 PHPUnit test runner warning:

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

WARNINGS!
Tests: 1, Assertions: 1, Warnings: 1.
28 changes: 28 additions & 0 deletions tests/end-to-end/logging/log-teamcity-invalid-socket.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Test runner emits warning when --log-teamcity is used with an invalid socket
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--log-teamcity';
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

. 1 / 1 (100%)

Time: %s, Memory: %s

There was 1 PHPUnit test runner warning:

1) Cannot log test results in TeamCity format to "socket://hostname:port:wrong": "socket://hostname:port:wrong" does not match "socket://hostname:port" format

WARNINGS!
Tests: 1, Assertions: 1, Warnings: 1.
28 changes: 28 additions & 0 deletions tests/end-to-end/logging/testdox-html-invalid-socket.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Test runner emits warning when --testdox-html is used with an invalid socket
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--testdox-html';
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

. 1 / 1 (100%)

Time: %s, Memory: %s

There was 1 PHPUnit test runner warning:

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

WARNINGS!
Tests: 1, Assertions: 1, Warnings: 1.
28 changes: 28 additions & 0 deletions tests/end-to-end/logging/testdox-text-invalid-socket.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Test runner emits warning when --testdox-text is used with an invalid socket
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--testdox-text';
$_SERVER['argv'][] = 'socket://hostname:port:wrong';
$_SERVER['argv'][] = __DIR__ . '/../_files/basic/SuccessTest.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

. 1 / 1 (100%)

Time: %s, Memory: %s

There was 1 PHPUnit test runner warning:

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

WARNINGS!
Tests: 1, Assertions: 1, Warnings: 1.

0 comments on commit 6ad43c7

Please sign in to comment.