Skip to content

MockWebServer tests sometimes fail on PHP 8.4 #921

@jtojnar

Description

@jtojnar

In #919, the tests fail on PHP 8.4 because of the following getting captured in the response:

Deprecated: Mf2\Parser::parse(): Implicitly marking parameter $context as nullable is deprecated, the explicit nullable type must be used instead in /home/jtojnar/Projects/simplepie/vendor/mf2/mf2/Mf2/Parser.php on line 1373

Deprecated: Mf2\Parser::parse_recursive(): Implicitly marking parameter $context as nullable is deprecated, the explicit nullable type must be used instead in /home/jtojnar/Projects/simplepie/vendor/mf2/mf2/Mf2/Parser.php on line 1401

Deprecated: Mf2\Parser::getRootMF(): Implicitly marking parameter $context as nullable is deprecated, the explicit nullable type must be used instead in /home/jtojnar/Projects/simplepie/vendor/mf2/mf2/Mf2/Parser.php on line 1506

Locally, I also started getting the following on master (32e7828), even though it seems to work fine on CI, presumably also by the warning terminating headers:

There were 5 failures:

1) SimplePie\Tests\Integration\HTTP\ClientsTest::testFileClientReturnsResponseOn429StatusCode
Failed asserting that 200 is identical to 429.

/home/jtojnar/Projects/simplepie/tests/Integration/HTTP/ClientsTest.php:106

2) SimplePie\Tests\Integration\HTTP\ClientsTest::testFileClientReturnsResponseOn500StatusCode
Failed asserting that 200 is identical to 500.

/home/jtojnar/Projects/simplepie/tests/Integration/HTTP/ClientsTest.php:125

3) SimplePie\Tests\Integration\HTTP\ClientsTest::testRedirectsChain with data set "curl" (SimplePie\HTTP\FileClient Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'http://127.0.0.1:45129/temp2'
+'http://127.0.0.1:45129/perm2'

/home/jtojnar/Projects/simplepie/tests/Integration/HTTP/ClientsTest.php:219

4) SimplePie\Tests\Integration\HTTP\ClientsTest::testRedirectsChain with data set "fsockopen" (SimplePie\HTTP\FileClient Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'http://127.0.0.1:43997/temp2'
+'http://127.0.0.1:43997/perm2'

/home/jtojnar/Projects/simplepie/tests/Integration/HTTP/ClientsTest.php:219

5) SimplePie\Tests\Integration\SimplePieTest::testSimplePieReturnsCorrectStatusCodeFromServerResponse
Failed asserting that 200 is identical to 429.

/home/jtojnar/Projects/simplepie/tests/Integration/SimplePieTest.php:149

Not much we can do until microformats/php-mf2#264 is resolved.

The only possible alternative would be:

diff --git a/src/MockWebServer.php b/src/MockWebServer.php
index d242f98..538ee3c 100644
--- a/src/MockWebServer.php
+++ b/src/MockWebServer.php
@@ -63,7 +63,7 @@ class MockWebServer {
 		$script = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR . 'server.php';
 
 		$stdout = tempnam(sys_get_temp_dir(), 'mockserv-stdout-');
-		$cmd    = sprintf("php -S %s:%d %s", $this->host, $this->port, escapeshellarg($script));
+		$cmd    = sprintf("php -d display_errors=Off -S %s:%d %s", $this->host, $this->port, escapeshellarg($script));
 
 		if( !putenv(self::TMP_ENV . '=' . $this->tmpDir) ) {
 			throw new Exceptions\RuntimeException('Unable to put environmental variable');

Perhaps something like that would be acceptable to @donatj.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions