Closed loic-couharde closed 5 years ago
If this scenario needs to be supported, then we'd need:
Overall, changing $_
variables should not affect testing, and tests that expose failures if that happens are extremely smelly.
Specifically, in the two cases listed above:
protected function initialize()
that is called post-construct isn't good design, and @hywan may be able to help further in fixing that later on.As an added suggestion, consider using @runInSeparateProcess
, if you have tests relying on super-globals or statics. I generally isolate anything that uses statics/globals (and all related anti-patterns) in such tests, at an extreme performance penalty, but usually works.
EDIT: this includes tests that rely on changing $_GLOBALS
We can update hoa/protocol
but we are certainly not the only ones doing so :-).
Thanks for the ping!
This not even fails vendor products it fails all our integration controller tests now.
PHPUnit allows to add server variable via configuration (like HTTP_HOST i.e.). These configuration settings are now thrown away when ever a new controller test is started.
The next problem is, that if the test fails and throws an exception the global variables are not restored and phpunit now fails hard.
Is this really expected behaviour?
Is this really expected behaviour?
No. I'll try to prepare another fix today, I have an idea and it could work for everyone! :)
@reinfi @loic-couharde @Ocramius I've prepared PR: https://github.com/zendframework/zend-test/pull/74 which depends on https://github.com/zendframework/zend-http/pull/165 - recognise correct base url.
looks good to me
We have some controller tests failing now with zend-test
3.2.1 (that includes changes from #66) because of this line in zend-session
:
https://github.com/zendframework/zend-session/blob/master/src/AbstractContainer.php#L260
Exception 'PHPUnit\Framework\Error\Notice' with message 'Undefined index: REQUEST_TIME' in ./vendor/zendframework/zend-session/src/AbstractContainer.php:260
Reverting to 3.2.0 fixes the tests.
Hi,
The #66 hotfix breaks many vendors since Global arrays are cleared on setUp(). For example I use spatie/phpunit-snapshot-assertions to make snapshots which use $_SERVER here or Hoa Protocol here. These are only 2 examples but it may have a huge impact on other large projects with many vendors.
Is it possible to consider fine fixing the problem encountered in #61 instead of clearing all global arrays ?
Thanks.