Skip to content

Fatal error: $this when not in object context in .../get[...]Service.php #25017

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

Closed
nicolas-grekas opened this issue Nov 18, 2017 · 0 comments
Closed

Comments

@nicolas-grekas
Copy link
Member

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4

Found when running LiipFunctionalTestBundle's test suite again symfony 3.4.
The issue is that phpunit's @runInSeparateProcess feature is very risky as it requires all files required before, even-though no all file are require-able as such.

Some ideas to fix this:

  1. enable processIsolation=true in the bundle's phpunit.xml.dist, which is free from the issue
  2. not split the container in several files for tests
  3. find a way around in phpunit-bridge

I hope 3 is actually possible, that'd be best.

@nicolas-grekas nicolas-grekas changed the title Fatal error: $this when not in object context in .../getCacheWarmerService.php Fatal error: $this when not in object context in .../get[...]Service.php Nov 18, 2017
nicolas-grekas added a commit that referenced this issue Nov 19, 2017
…phpunit (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[Bridge\PhpUnit] Disable broken auto-require mechanism of phpunit

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25017
| License       | MIT
| Doc PR        | -

It took me all the flight back from Cluj to figure out this is the only way to solve this nasty issue created by phpunit generating inlined `require_once` in the global scope for isolated tests.
This mechanism predates the autoloading mechanism, and it's behavior is just hardcoded.
Needs to be merged in 3.4, where the split container triggers this situation very quickly.

Will allow removing the `function_exists('__phpunit_run_isolated_test')` workarounds already in place in the code base (2.7 up to master.)

Commits
-------

0577d20 [Bridge\PhpUnit] Disable broken auto-require mechanism of phpunit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants