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

Dependency issue with test requirement #19

Closed
weierophinney opened this issue Dec 31, 2019 · 9 comments
Closed

Dependency issue with test requirement #19

weierophinney opened this issue Dec 31, 2019 · 9 comments

Comments

@weierophinney
Copy link
Member

This component ships a trait used by other components in tests.
Now with 07d53d3 the tests have been upgraded to PHPUnit5 and tests of other components fails because they still using PHPUnit4.
E.g.: https://travis-ci.org/marc-mabe/zend-cache/jobs/203261654

The main problem is not to have a reusable trait for tests or the upgraded PHPUnit dependency but:

  • The dependency of PHPUnit5 is defined in require-dev - so only valid running zend-servicemanager in development environment but not verified by other components
  • Can't be moved to require as then every production environment would load PHPUnit and it's dependencies
  • The test trait will be available for everyone even in production environment but they shouldn't use it 😕
  • The test trait is in namespace Zend\ServiceManager\Test but it should be in ZendTest\*

To solve this I would do the following (like what I started to do with splitting zend-cache):

  • create own repo for reusable test classes (like zend-servicemanager-test)
    • set autoload (not autoload-dev) to load the common test classes in namespace ZendTest\*
    • set require (not require-dev) to depend on zend-servicemanager and everything else required to use these test classes
  • add require-dev: zend-servicemanager-test in this component and all components using this class
    -> Now the dependencies of such test classes are defined by composer and they are not part of any production environment

How this would look like as I started to do that with zend-cache:

Ping @weierophinney @Ocramius


Originally posted by @marc-mabe at zendframework/zend-servicemanager#182

@weierophinney
Copy link
Member Author

This is causing problems with Zend Validator too: https://travis-ci.org/zendframework/zend-validator


Originally posted by @akrabat at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

i also start working to update all modules, which i found, to work with the latest phpunit version.


Originally posted by @kokspflanze at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

Honestly, I think the approach by @kokspflanze is the best one for us to take. PHPUnit 5.7 is considered "legacy" currently (technically "old stable"), with version 6.0 the current stable release; the PHPUnit 4 series is no longer supported. As such, we need to start updating all components to pin them to newer versions. PHPUnit 5 is needed when testing against PHP 5.6, and PHPUnit 6 for versions 7 and up. We've done this across a number of components recently, most notably the Expressive components, and have approaches that work across each in terms of testing on Travis.

The main "gotchas" we've observed when updating are:

  • setExpectedException() goes away, and needs to be replaced with expectException(), plus optionally expectExceptionMessage().
  • PHPUnit\Framework\TestCase should be used instead of PHPUnit_Framework_TestCase.
  • A number of commonly used classes from the phpunit package do not have namespaced, forwards-compatibility shims, which require doing things like class_alias hacks, to allow using namespaced versions of classes that will work under both major versions of PHPUnit.

I've found that most adaptations to components take less than an hour, and I see that @kokspflanze has already started submitting a number of these in the past week; if we can get these merged soon, and get others to help in the effort, we can get these cases sorted fairly quickly.

While we could certainly split the test trait(s) into their own package, I hate to do this, as it adds yet another dependency during normal development, particularly when this is a transient problem.


Originally posted by @weierophinney at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

@weierophinney from my site i see the biggest problem to support PHPUnit 4, 5 and 6, some modules like zend-validator start with min php 5.5 so they want PHPUnit 4 but there is no expectException method, these method added with phpunit 5.2 code, so i stuck atm there to find a good solution without writing hacks.

maybe someone have a good solution for that.

from my site i try 1 or 2 modules each week, some modules take bit longer some are less than 1hour done.


Originally posted by @kokspflanze at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

@kokspflanze

…to support PHPUnit 4, 5 and 6…

Why? PHP 5.5 and PHPUnit 4.8 are no longer supported!


Originally posted by @froschdesign at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

can i realy remove php 5.5 in modules like zend-validator?


Originally posted by @kokspflanze at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

@kokspflanze — We can issue new minor releases that bump the PHP requirement to ^5.6 || ^7.0 for any component at any time; I'm a bit surprised we haven't done so with zend-validator already, as we've been steadily doing so with new component releases for the past year!


Originally posted by @weierophinney at zendframework/zend-servicemanager#182 (comment)

@weierophinney
Copy link
Member Author

okay thats cool=) didnt know it that we can easy set it to the latest version=) that save many time


Originally posted by @kokspflanze at zendframework/zend-servicemanager#182 (comment)

@GeeH
Copy link
Contributor

GeeH commented Jun 8, 2020

I'm closing this as we are now targeting PHPUnit 7.5 with plans to target @latest very soon.

@GeeH GeeH closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants