-
Notifications
You must be signed in to change notification settings - Fork 150
Drop php 5.4 and 5.5 support #205
Drop php 5.4 and 5.5 support #205
Conversation
No can do, at least not yet. We provide support for versions prior to 5.6 to accommodate the symfony ecosystem (as v2 introduced the PSR-7 bridge, and the last LTS still supports 5.4). We can look at this next year. |
I'm thinking what we'll do is one last minor version supporting pre-5.6 versions, and then mark that an LTS version that will only receive security and/or critical bugfixes. We can then do a 2.0 version sooner rather than later, and move any new features to that. I'll come back to this in a few weeks so we can proceed. |
test/CallbackStreamTest.php
Outdated
public function testTell() | ||
{ | ||
$stream = new CallbackStream(function () { | ||
}); | ||
|
||
$this->setExpectedException(RuntimeException::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use expectException()
instead, as setExpectedException()
is deprecated and will be removed in phpunit 6
@weierophinney a few weeks go away, what about this? |
Currently on vacation, @snapshotpl; will review next week. |
test/Request/SerializerTest.php
Outdated
->getMock(); | ||
|
||
$stream->expects($this->once())->method('isReadable') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the expects
? Surely in these cases we want to ensure isReadable
is only called once still? (same question applies to other similar changes). Only thing I can think of is that because an exception is thrown that the mock expectations are not checked? (I don't know off my head without checking)
new JsonResponse($resource); | ||
} | ||
|
||
public function testJsonErrorHandlingOfBadEmbeddedData() | ||
{ | ||
if (version_compare(PHP_VERSION, '5.5', 'lt')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuss! 👍
@@ -89,13 +89,13 @@ public function testGetSize() | |||
$this->assertNull($ret); | |||
} | |||
|
|||
/** | |||
* @expectedException RuntimeException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should try to avoid unrelated changes; as far as I know, there's nothing broken about @expectedException
is there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll allow it. Semantically, having the call to expectException()
immediately prior to the code that raises the exception is better. While I realize it's unrelated, since this is updating the PHPUnit version already, we might as well do some cleanup.
I've changed my mind on this, and am scheduling this for 1.5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, and takes care of a rather largish patch I didn't really want to work on myself. 😄
There are a few issues, however, which I've noted. The big general issues that apply throughout, however, are:
expectException()
does not behave the same assetExpectedException()
; it does not accept a second argument with the expected exception message. You'll need to break your two-argument calls to this method into calls toexpectException()
+expectExceptionMessage()
.- In many places, you refactored method mocks to remove
expects()
calls; these need to be re-instated, as in most cases, we are testing foronce()
orany()
, and want to be explicit about which is correct.
composer.json
Outdated
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^4.6 || ^5.5", | ||
"zendframework/zend-coding-standard": "~1.0.0", | ||
"phpunit/phpunit": "^5.6 || ^6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get a bit more specific on these, as there's breakage in early versions of 6.0 and 5.6 that have often led to test failures in other repos. Try ^5.7.16 || ^6.0.8
here.
composer.json
Outdated
"phpunit/phpunit": "^4.6 || ^5.5", | ||
"zendframework/zend-coding-standard": "~1.0.0", | ||
"phpunit/phpunit": "^5.6 || ^6.0", | ||
"zendframework/zend-coding-standard": "^1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the few that needs to use the ~
operator, as we don't want new PRs to suddenly fail due to new rules being added to the standard.
@@ -89,13 +89,13 @@ public function testGetSize() | |||
$this->assertNull($ret); | |||
} | |||
|
|||
/** | |||
* @expectedException RuntimeException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll allow it. Semantically, having the call to expectException()
immediately prior to the code that raises the exception is better. While I realize it's unrelated, since this is updating the PHPUnit version already, we might as well do some cleanup.
test/MessageTraitTest.php
Outdated
@@ -212,8 +216,9 @@ public function invalidHeaderValues() | |||
*/ | |||
public function testWithHeaderRaisesExceptionForInvalidValueType($value) | |||
{ | |||
$this->setExpectedException('InvalidArgumentException', 'Invalid header value'); | |||
$message = $this->message->withHeader('X-Foo', $value); | |||
$this->expectException(InvalidArgumentException::class, 'Invalid header value'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't doing what you think.
expectException()
only accepts one argument, the exception type to test for. If you also want to test the message, you need to add an additional call to expectExceptionMessage()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
test/MessageTraitTest.php
Outdated
@@ -229,8 +234,9 @@ public function testWithHeaderReplacesDifferentCapitalization() | |||
*/ | |||
public function testWithAddedHeaderRaisesExceptionForNonStringNonArrayValue($value) | |||
{ | |||
$this->setExpectedException('InvalidArgumentException', 'must be a string'); | |||
$message = $this->message->withAddedHeader('X-Foo', $value); | |||
$this->expectException(InvalidArgumentException::class, 'must be a string'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, and throughout; any two-argument calls to setExpectedException()
need to be re-written as two discrete calls to expectException()
and expectExceptionMessage()
.
test/Request/SerializerTest.php
Outdated
|
||
$stream->expects($this->once())->method('isSeekable') | ||
->will($this->returnValue(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why these mocks were rewritten. The combination of getMockBuilder()
+ getMock()
works in PHPUnit 5.6+ and 6.0+, as does the syntax of expects()
. The changes you have introduced loosen the expectations by removing the expects($this->once())
constraints...
test/Response/SerializerTest.php
Outdated
->will($this->returnValue(true)); | ||
$stream = $this->createMock(StreamInterface::class); | ||
$stream->method('isReadable')->will($this->returnValue(true)); | ||
$stream->method('isSeekable')->will($this->returnValue(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here about the removal of expects()
.
@@ -43,5 +42,7 @@ public function testPassesBufferLevelToSapiStreamEmitter() | |||
); | |||
$server->setEmitter($emitter->reveal()); | |||
$server->listen(); | |||
|
|||
ob_end_clean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added? Was it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discovered why when removing locally; PHPUnit flags it as a risky test due to the fact it did not close its own output buffers.
test/ServerRequestFactoryTest.php
Outdated
{ | ||
$_SERVER = $this->globalServer; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this functionality needed? The @backupGlobals
and @preserveGlobalState
annotations are enabled
by default, which should make this unnecessary. What did you observe that led to their addition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test testFromGlobalsUsesCookieSuperGlobalWhenCookieHeaderIsNotSet()
was causing inconsistent results due to superglobal state otherwise. This is better alleviated by the combination of @runInSeparateProcess
and @preserveGlobalState disabled
annotations.
test/ServerTest.php
Outdated
->method('getBody') | ||
->willReturn($responseBody); | ||
$this->response | ||
->expects($this->any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expects()
calls need to be re-instated; these were there for a reason.
Drop php 5.4 and 5.5 support
@snapshotpl I've pushed the changes I've requested to your branch at this time, and will rebase to incorporate them into your own commits once I can verify the changes pass continuous integration. |
3148b37
to
a0b4008
Compare
a0b4008
to
adb5925
Compare
Thanks, @snapshotpl |
No description provided.