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

Not working at all with global PHPUnit #48

Closed
soullivaneuh opened this issue Jun 19, 2015 · 4 comments
Closed

Not working at all with global PHPUnit #48

soullivaneuh opened this issue Jun 19, 2015 · 4 comments

Comments

@soullivaneuh
Copy link
Contributor

If we run tests based on your library with a global phpunit binary, it fails. But it works with phpunit as a project dependency.

See more details here: sonata-project/SonataAdminSearchBundle#16 (comment)

And the related test case: https://github.com/sonata-project/SonataAdminSearchBundle/blob/72b0a5c5202ae8da33b5c1ea7936afde8e117e1d/Tests/DependencyInjection/Compiler/DatagridBuilderInjectionCompilerPassTest.php

We can't figure out why.

Maybe do you have an explanation?

Thanks.

@greg0ire
Copy link
Contributor

I found the explanation, this can be closed.
For the record, the phpunit binary starts like this :

foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
    if (file_exists($file)) {
        define('PHPUNIT_COMPOSER_INSTALL', $file);
        break;
    }
}

When the system's phpunit is used, the autoload file is (in my case) ~/.composer/vendor/phpunit/phpunit/../../autoload.php

This might be a bug in phpunit. It should look in the current working directory first, I think.

@soullivaneuh
Copy link
Contributor Author

@greg0ire I'll keep it open unless a solution is found, thanks.

@greg0ire
Copy link
Contributor

You should close it, because it has nothing to do with this package. The problem probably arises at the very first step : there is no dot in the output, signalling that a test was successful. I think if you remove this test, it will fail on another test, as soon as php tries to autoload something. Since it has the wrong autoloader, it can't autoload anything that isn't also require globally. It probably won't be able to load any class from the library under test, for instance.

Another reason to close this is that I have filed an issue in the right place

@soullivaneuh
Copy link
Contributor Author

Thanks @greg0ire.

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