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
Unable to Mock a class: unserialize(): Error at offset 29 of 30 bytes
#1409
Comments
I don't know if this is going to be fixable in PHP 5.5.16. Due to security concerns, certain internal classes can no longer be instantiated without calling their constructor. I did some research into this a while ago, and @Ocramius provides the library we use for instantiation and has done much more research into this lately, so maybe he can give us a status update on the likelyhood of this working now or in the future. |
@whatthejeff I think instantiator doesn't support |
Thanks, @Ocramius :) @morafabio thanks for bringing this to our attention. Unfortunately, there's not much we can do here. For future reference, the library we use for instantiation is https://github.com/doctrine/instantiator. Any further discussion regarding instantiation should probably happen over there. |
Thanks guys, but another question. I did a quick test and as I can see here http://3v4l.org/F4fqb, now in PHP 5.6 an internal class can be instantiated without invoking its constructor. Not the same for 5.4.x and 5.5.x, but some minor version support the "unserialization" trick: http://3v4l.org/jqvE2. I'm a bit confused at this point: regardless of my PHP minor version, should I write a test case using mock SplFileInfo or not? @Ocramius in your opinion, what should Instantiator support and what not? |
@morafabio I think that I cannot support |
See [1] for more information. [1] sebastianbergmann/phpunit#1409
Today I upgraded to PHP 5.5.16 and I have an issue mocking a library.
It's
\Symfony\Component\HttpFoundation\File\File
.The following code returns an exception:
I have created a repo to easily reproduce the bug, just
git clone
,composer install
and launch./phpunit
: https://github.com/morafabio/phpunit-unserialize-mock-bugThis is really similar to this bug: mockery/mockery#339.
Actual
Here is my environment:
Expected
Note that with a PHP older than 5.5.13 it works fine, eg.:
The text was updated successfully, but these errors were encountered: