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

Serialization error #1

Closed
JeffreyWay opened this issue Jul 23, 2013 · 9 comments
Closed

Serialization error #1

JeffreyWay opened this issue Jul 23, 2013 · 9 comments
Labels

Comments

@JeffreyWay
Copy link

I'm trying to test this out, but get "Exception: Serialization of 'Closure' is not allowed" every time I run phpunit. PHPUnit has issues with serializing closures, but I'm not sure why that would affect my machine and not yours.

Here is my source code. I'm not even using any of the functionality yet. Just trying to get the tests to run. See anything glaringly wrong?

https://github.com/JeffreyWay/Temporary-Bug

I'm using PHPUnit 3.7.19 and PHP 5.4.1.

@DavertMik
Copy link
Member

Attaching your pic for not to lose it.

http://d.pr/i/u7nC

@DavertMik
Copy link
Member

Just remembered. I met this issue before and fixed it in Codeception.
PHPUnit backups all global variables and static class properties, and serializes them.
Yep, it checks for \Closure but it does it like this:

<?php
                            if (!$value instanceof Closure) {
                                $backup[$name] = serialize($value);
                            }

?>

It's PHPUnit_Util_GlobalState.

I assume that if value is an object itself, or array with closure, this check passes, yet serialization fails.
Hard to say what property fails this.

@DavertMik
Copy link
Member

So you can fix it by disabling backup globals.

<phpunit bootstrap="tests/bootstrap.php" colors="true" backupGlobals="false">

I'm not sure this parameter was really valuable and which of vendor classes store closures in static properties.

@JeffreyWay
Copy link
Author

Yeah, I tried that at one point. But now I get:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in /Users/Jeffrey/Desktop/aspect/vendor/lisachenko/go-aop-php/src/Go/Aop/Framework/ClosureStaticMethodInvocation.php on line 79

@lisachenko
Copy link
Contributor

@JeffreyWay AspectMock mocks itself ) so there is a recursion. @DavertMik this is related to the within(**) pointcut. It cuts AspectMock itself.

@lisachenko
Copy link
Contributor

My bootstrap is using excludePaths option that restricts AOP for vendor libraries:

$kernel = \AspectMock\Kernel::getInstance();
$kernel->init([
    'debug' => true,
    'cacheDir' => __DIR__.'/../tests/cache',
    'excludePaths' => [__DIR__.'/../vendor']
]);

@JeffreyWay
Copy link
Author

excludePaths did the trick for me! Thanks. :)

@DavertMik
Copy link
Member

@lisachenko
Thanks, I need to update the docs to reflect this.
Anyway I didn't get includePath/excludePath working with cache. It still caches everything with vendors. Might be issue in #2.

@lisachenko
Copy link
Contributor

@DavertMik it's ok to have files in the cache. includePaths option controls only weaver of aspects, but there is a need to inject filter into includes, so there is transformation of files. It can be nice to create symlinks for the cases when original file equals to transformed one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants