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

added phpunit 6 #47

Merged
merged 5 commits into from
Jul 11, 2017
Merged

added phpunit 6 #47

merged 5 commits into from
Jul 11, 2017

Conversation

kokspflanze
Copy link
Contributor

updated some tests with ::class
changed composer.json with phpunit to min 5.7.14 or 6.0.7

updated some tests with ::class
changed composer.json with phpunit to min 5.7.14 or 6.0.7
@@ -193,6 +194,13 @@ public function testAssertListenerAtPriorityFailsWhenListenerIsNotFound()
$arguments['event'],
$arguments['priority']
), $e->getMessage(), sprintf('Assertion failure message was unexpected: %s', $e->getMessage()));
// for PHPUnit 5.7
Copy link
Member

Choose a reason for hiding this comment

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

Please no dependencies to a specific version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats the fallback for PHPUnit5, thats not just phpunit5.7

that exception class doesnt exist in phpunit 6, so there must be a fallback, other way would be a class_alias or a check if the class exists.

Copy link
Member

Choose a reason for hiding this comment

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

Please have a look how @weierophinney did it in another repo:
zendframework/zend-component-installer@654983e
I'd suggest the same way here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh i missed that, is that workflow is expected, than i will change that sure =)

@@ -9,7 +9,7 @@

namespace Zend\EventManager\Test;

use PHPUnit_Framework_Assert as Assert;
use PHPUnit\Framework\Assert as Assert;
Copy link
Member

Choose a reason for hiding this comment

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

Alias Assert here is redundant.

@michalbundyra
Copy link
Member

@kokspflanze We need also update travis configuration, to install PHPUnit 5.7 on PHP5.6, please see changes for example here:
https://github.com/zendframework/zend-component-installer/blob/master/.travis.yml#L16
and install section there.

composer.json Outdated
@@ -32,7 +32,7 @@
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/PHPUnit": "^5.6",
"phpunit/PHPUnit": "^5.7.14 || ^6.0.7",
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest also swap order here, please see:
zendframework/zend-expressive-skeleton@39ef689

Alias Assert is redundant
update travis configuration
swap order of phpunit version
@kokspflanze
Copy link
Contributor Author

done, i just added in the autoload file a class_exist check, to remove the warning

Copy link
Member

@michalbundyra michalbundyra left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -9,7 +9,7 @@

namespace Zend\EventManager\Test;

use PHPUnit_Framework_Assert as Assert;
use PHPUnit\Framework\Assert;
Copy link
Member

Choose a reason for hiding this comment

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

Why not using $this->assertTrue() instead of Assert::assertTrue()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why?

in that case we are in a trait class and the class that this trait import can not have that method.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

Sure? If we look at the comments of the class:

Trait providing utility methods and assertions for use in PHPUnit test cases.

😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

before the Assert class it was with the TestCase class

be75ec1

from my site i see the Assets class as better solution, with $this it could be possible that it break smth in other tests if someone not use the TestCase as parent-class. also we have a autocomplete and no warning that the method not exist.

Copy link
Member

Choose a reason for hiding this comment

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

@froschdesign In a trait it's only possible to define an abstract method to define that a specific method needs to be available but that does not work with __call() so it gets marked red in good IDEs. Using the direct assert seems to be more clear and the trait itself can be tested much better.

Copy link
Member

Choose a reason for hiding this comment

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

I fine with it. No extra discussion needed. (Look at the smiley!)

@froschdesign
Copy link
Member

@kokspflanze

The topic of this PR is "added phpunit 6", but you provide an all-in-one-commit:

  • namespace imports
  • class names with ::class
  • expectException and expectExceptionMessage
  • fallback

This may be necessary, but not in one commit! It's fine to add all this changes to one PR, but please create separate commits for each problem. We work with a version control system and these all-in-one-commits breaks this system. Try a cherry-pick or try to read the history.

Each individual change should be one commit.

(Added benefit: a review becomes easier and faster!)

@kokspflanze
Copy link
Contributor Author

@froschdesign no problem to split it in more commits, but that week is no much space, hope its okay if i do that next week.

didnt know that this should be in more commits, it was for me one little task.

@froschdesign
Copy link
Member

@kokspflanze

…but that week is no much space, hope its okay if i do that next week.

I can live with this PR.

@marc-mabe What are you saying?

didnt know that this should be in more commits, it was for me one little task.

Which mixes different problems!


Each individual change should be one commit.

That's not a specific feature or requirement of Zend Framework, GitHub or me. That's the principle of a version control system.

@weierophinney weierophinney merged commit ba3af00 into zendframework:master Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
weierophinney added a commit that referenced this pull request Jul 11, 2017
@weierophinney
Copy link
Member

Thanks, @kokspflanze

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