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

Release 3.2.1 breaks vendors behavior #71

Closed
loic-couharde opened this issue Dec 11, 2018 · 8 comments · Fixed by #74
Closed

Release 3.2.1 breaks vendors behavior #71

loic-couharde opened this issue Dec 11, 2018 · 8 comments · Fixed by #74

Comments

@loic-couharde
Copy link

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.

@Ocramius
Copy link
Member

Ocramius commented Dec 11, 2018

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:

@Ocramius
Copy link
Member

Ocramius commented Dec 11, 2018

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

@Hywan
Copy link

Hywan commented Dec 11, 2018

We can update hoa/protocol but we are certainly not the only ones doing so :-).

Thanks for the ping!

@reinfi
Copy link

reinfi commented Dec 17, 2018

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?

@michalbundyra
Copy link
Member

Is this really expected behaviour?

No. I'll try to prepare another fix today, I have an idea and it could work for everyone! :)

@michalbundyra
Copy link
Member

@reinfi @loic-couharde @Ocramius I've prepared PR:
#74 which depends on
zendframework/zend-http#165 - recognise correct base url.

@reinfi
Copy link

reinfi commented Jan 1, 2019

looks good to me

@jaydiablo
Copy link

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.

weierophinney added a commit that referenced this issue Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants