Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to require PHP 7.0 only (not a later version) using an annotation #2386

Closed
ondrejmirtes opened this issue Dec 4, 2016 · 3 comments
Closed
Labels
type/enhancement A new idea that should be implemented
Milestone

Comments

@ondrejmirtes
Copy link

Hello,
there's no way to require a test to run on PHP 7.0 and not on PHP 7.1 if I have a test that tests specifically a situation that makes sense only on PHP 7.0. The @requires annotation means "this version and all later versions" so I have to use a custom if condition with markTestSkipped.

@sebastianbergmann sebastianbergmann added the type/enhancement A new idea that should be implemented label Jan 2, 2017
@dnaber-de
Copy link
Contributor

dnaber-de commented Mar 31, 2017

So a possible solution would be to use version constraints (like for example used by Composer). In your case that would be:

/**
 * @requires PHP ~7.0
 */
public function testRunsOnlyOn70 { /*… */ }

In order to maintain BC @requires PHP 5.6.3 must still be interpreted as @requires PHP <=5.6.3 @requires PHP >=5.6.3 for example. https://github.com/phar-io/version can be used for parsing the version constraints as it will be a dependency as of PHPUnit 6.1 anyway.

@sebastianbergmann
Copy link
Owner

Re: #2386 (comment)

I think you mean @requires PHP >= 5.6.3 instead of @requires PHP <= 5.6.3.

@dnaber-de
Copy link
Contributor

Of course, thanks. Fixed the typo.

dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Mar 31, 2017
Use phar-io/version to parse and compare version
constraints to PHP version. See sebastianbergmann#2386
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Mar 31, 2017
Use phar-io/version to parse and compare version
constraints to PHP version. See sebastianbergmann#2386
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Apr 1, 2017
In order to maintain BC, existing keys are no
longer used. Instead a new key is introduced.
See sebastianbergmann#2386
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Apr 1, 2017
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Apr 1, 2017
* Check version constraint compliance also for
PHPUnit requirements
* Refactor method name and signature of
Util\Test::semanticPhpVersion()
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Apr 1, 2017
dnaber-de added a commit to dnaber-de/phpunit that referenced this issue Apr 1, 2017
sebastianbergmann pushed a commit that referenced this issue Apr 1, 2017
Use phar-io/version to parse and compare version
constraints to PHP version. See #2386
sebastianbergmann pushed a commit that referenced this issue Apr 1, 2017
In order to maintain BC, existing keys are no
longer used. Instead a new key is introduced.
See #2386
sebastianbergmann pushed a commit that referenced this issue Apr 1, 2017
* Check version constraint compliance also for
PHPUnit requirements
* Refactor method name and signature of
Util\Test::semanticPhpVersion()
@sebastianbergmann sebastianbergmann added this to the PHPUnit 6.1 milestone Apr 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

3 participants