Skip to content

Commit 7a07c2f

Browse files
Add tests for invalid sockets for logging
1 parent 660ecf9 commit 7a07c2f

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed
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)