Behat / Gherkin

Gherkin parser, written in PHP for Behat project
MIT License
1.05k stars 92 forks source link

Use new PHPUnit Framework TestCase and expectException in unit test code #172

Closed phil-davis closed 4 years ago

phil-davis commented 4 years ago

So that the unit test code is more up-to-date in preparation for phpunit6.

Note: On PHP 5.6 the Travis CI runs with PHPUnit 5.7.27 - so actually there is no CI any more that run with PHPUnit 4.5 (which is mentioned in composer.json. But I guess we leave that in composer.json because somebody might try to locally run the unit tests with some more ancient version of PHP.

Note 2: removed PHPUnit 4 and PHP 5.3 5.4 5.5 support.

stof commented 4 years ago

With composer.json saying that we support PHP 5.3+, not having these versions on CI is actually an issue.

phil-davis commented 4 years ago

With composer.json saying that we support PHP 5.3+, not having these versions on CI is actually an issue.

@stof What do you want to do about that? Stop official support for those ancient PHP versions, or add back CI for PHP 5.3 5.4 5.5?

stof commented 4 years ago

Well, given that the next behat/behat release will require PHP 7.2+, I think it might be fine to change things in this repo too (and then this PR is fine).

phil-davis commented 4 years ago

@stof or anyone ping for review

Or maybe we move straight to dropping all the old PHP support and just support PHP 7.2+ to match what is happening anyway in Behat/Behat. If you want to do that, then let me know and I will make a PR and close this. That will actually be easy because there will be no need to think hard about which methods exist or not in which old phpunit major versions.

phil-davis commented 4 years ago

Needs a decision about issue #176 - Drop older PHP versions. If that goes ahead now, then we can do a different PR with more changes and no need to worry about what PHPUnit stuff works in ancient versions.

phil-davis commented 4 years ago

Rebased just now to get CI with master commits that were merged yesterday. This PR is waiting on a decision about PHP version support.

phil-davis commented 4 years ago

@stof it's up to you to decide if this is merged now, or wait for the PHP 7.2 decision and then directly do #178 or whatever.

ciaranmcnulty commented 3 years ago

When I check out master and run the tests, I get the error:

Fatal error: Uncaught Error: Class 'PHPUnit\Framework\TestCase' not found

It seems related to this PR? Any ideas what's going on?

PHP7.4.13 and it's PHPUnit 5.2.7 that's installed

phil-davis commented 3 years ago

In PHPUnit 5 the class is called PHPUnit_Framework_TestCase

The unit test code no longer supports that ancient PHPUnit version. (or maybe it is PHPUnit4 that does not know about the "new" class)

phil-davis commented 3 years ago

https://github.com/sebastianbergmann/phpunit/releases/tag/5.7.26

5.7 is the latest PHPUnit5 - maybe the new class was added somewhere between 5.2 and 5.7

stof commented 3 years ago

it was added in 4.8.35 and 5.7

ciaranmcnulty commented 3 years ago

Perhaps we need a —prefers-lowest build

phil-davis commented 3 years ago

In #178 we drop support for old PHP versions, and so phpunit5 will not be relevant any more anyway.

ciaranmcnulty commented 3 years ago

Yeah but I’d like a stable release before that

phil-davis commented 3 years ago

@ciaranmcnulty PR #184 should be enough. That will ensure that people trying to run the unit tests with an old PHP will at least get phpunit 5.7 installed, not lower.