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

Patchwork warning when included in PHPUnit bootstrap #38

Closed
cmounce opened this issue Feb 19, 2016 · 5 comments
Closed

Patchwork warning when included in PHPUnit bootstrap #38

cmounce opened this issue Feb 19, 2016 · 5 comments

Comments

@cmounce
Copy link

cmounce commented Feb 19, 2016

I have a PHPUnit bootstrap file that looks like this:

<?php
require_once('./vendor/antecedent/patchwork/Patchwork.php');
require_once('./vendor/autoload.php');
// other stuff...

Patchwork is the first file included. But when I run "phpunit" from the command line, I get the message:

PHP Warning: Please import Patchwork from a point in your code where no user-defined function, class or trait is yet defined. composer\autoload\includefile() and possibly others currently violate this. in /home/cmounce/Documents/patchwork-phpunit/vendor/antecedent/patchwork/Patchwork.php on line 93

This is happening with Patchwork 1.4.1. Both PHPUnit and Patchwork are Composer dependencies of the project:

{
    "require-dev": {
        "phpunit/phpunit": "^4.8",
        "antecedent/patchwork": "1.4.1"
    }
}
@bswatson
Copy link

Running into this same problem as well. Switched back to 1.4 until this is cleared up.

This appears to have been introduced by the changes related to #36.

antecedent added a commit that referenced this issue Feb 22, 2016
@antecedent
Copy link
Owner

I apologize for still not having documented this, but this can be remedied by creating a patchwork.json with the following contents:

{
    "suppress-warnings": [
        "composer*"
    ]
}

Version 1.4.2, which is now live, simply includes this setting by default.

@cmounce
Copy link
Author

cmounce commented Feb 23, 2016

Awesome! Thanks for the fast turnaround time in fixing this issue!

@cmounce cmounce closed this as completed Feb 23, 2016
@ericmann
Copy link

Hmm ... I added the patchwork.json file with those contents and, using 1.4.2, still see the warnings repeatedly. This breaks headless execution via tools like Travis and I still have to roll back to 1.4.0 to get things to work right. Any other thoughts?

@antecedent
Copy link
Owner

@ericmann: for a quick fix, you can always take the {"suppress-warnings": ["*"]} route. However, Patchwork is probably having problems with a different method/function here; its name should show up in the warnings. If it's one that's a part of a usual testing setup, please make a pull request to include it in the default patchwork.json.

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

4 participants