Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Drop php 5.4 and 5.5 support #205

Merged
merged 14 commits into from
Aug 22, 2017

Conversation

snapshotpl
Copy link
Contributor

No description provided.

@weierophinney
Copy link
Member

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.

@weierophinney
Copy link
Member

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.

@weierophinney weierophinney added this to the 2.0.0 milestone Oct 11, 2016
public function testTell()
{
$stream = new CallbackStream(function () {
});

$this->setExpectedException(RuntimeException::class);
Copy link
Contributor

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

@snapshotpl snapshotpl changed the base branch from master to develop December 28, 2016 20:17
@snapshotpl
Copy link
Contributor Author

@weierophinney a few weeks go away, what about this?

@weierophinney
Copy link
Member

Currently on vacation, @snapshotpl; will review next week.

->getMock();

$stream->expects($this->once())->method('isReadable')
Copy link

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')) {
Copy link

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
Copy link

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?

Copy link
Member

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.

@kokspflanze kokspflanze mentioned this pull request Jun 4, 2017
@weierophinney weierophinney modified the milestones: 1.5.0, 2.0.0 Aug 18, 2017
@weierophinney
Copy link
Member

I've changed my mind on this, and am scheduling this for 1.5.0.

Copy link
Member

@weierophinney weierophinney left a 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 as setExpectedException(); 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 to expectException() + 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 for once() or any(), 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",
Copy link
Member

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",
Copy link
Member

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
Copy link
Member

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.

@@ -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');
Copy link
Member

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@@ -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');
Copy link
Member

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().


$stream->expects($this->once())->method('isSeekable')
->will($this->returnValue(false));
Copy link
Member

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...

->will($this->returnValue(true));
$stream = $this->createMock(StreamInterface::class);
$stream->method('isReadable')->will($this->returnValue(true));
$stream->method('isSeekable')->will($this->returnValue(false));
Copy link
Member

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();
Copy link
Member

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?

Copy link
Member

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.

{
$_SERVER = $this->globalServer;
}

Copy link
Member

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?

Copy link
Member

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.

->method('getBody')
->willReturn($responseBody);
$this->response
->expects($this->any())
Copy link
Member

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.

weierophinney added a commit to snapshotpl/zend-diactoros that referenced this pull request Aug 22, 2017
@weierophinney
Copy link
Member

@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.

@weierophinney weierophinney merged commit adb5925 into zendframework:develop Aug 22, 2017
weierophinney added a commit that referenced this pull request Aug 22, 2017
weierophinney added a commit that referenced this pull request Aug 22, 2017
@weierophinney
Copy link
Member

Thanks, @snapshotpl

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants