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

Running with --process-isolation yields parse error on global data with single quotes #2

Closed
beamrider9 opened this issue Aug 2, 2010 · 2 comments

Comments

@beamrider9
Copy link

The code that writes out global PHP data to a serialized string doesn't take into account the case where the serialized data contains single quotes - when it does, the string being passed to unserialize results in a parse error.

It's this line:

http://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/Util/GlobalState.php#L323

@beamrider9
Copy link
Author

And just to state the obvious, I circumvented this by changing that line in GlobalState.php to escape single quotes in the data - e.g.

From:
return 'unserialize('' . serialize($variable) . '')';

To:
return 'unserialize('' . str_replace("'", "'", serialize($variable)) . '')';

@sebastianbergmann
Copy link
Owner

Fixed.

axiac pushed a commit to axiac/phpunit that referenced this issue May 8, 2018
Now gives better error message:
```
There was 1 error:

1) ExampleTest::testExample
PHPUnit_Framework_Exception: Argument sebastianbergmann#2 (string#__construct)of PHPUnit_Framework_MockObject_Generator::getMock() must be a array

/<path>/ExampleTest.php:8
```

Instead of:
```
There was 1 error:

1) ExampleTest::testExample
InvalidArgumentException: 

/<path>/ExampleTest.php:8
```
@shinseihasu shinseihasu mentioned this issue Jul 31, 2019
Closed
This issue was closed.
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