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

Error: Please import Patchwork from a point in your code where no user-defined function, class or trait is yet defined. (BrainMonkey + PHPUnit) #37

Closed
k00ni opened this issue Feb 15, 2016 · 0 comments

Comments

@k00ni
Copy link

@k00ni k00ni commented Feb 15, 2016

Problem

Overview:

I have a minimal setup with:

  • BrainMonkey
  • PHPUnit
  • Patchwork

After a start a simple test, i always get the following error:

Please import Patchwork from a point in your code where no user-defined function, 
class or trait is yet defined. composerrequire8af9bf7de4cc77dbd99964afd34dcbac() and 
possibly others currently violate this.
/../vendor/antecedent/patchwork/Patchwork.php:94
/../vendor/antecedent/patchwork/Patchwork.php:96
/../vendor/brain/monkey/src/Monkey.php:44
/../vendor/brain/monkey/src/Monkey.php:60
/../tests/src/PluginsFirst/SerialKeyChecker/Test/UnitTestCase.php:13
/../tests/src/PluginsFirst/SerialKeyChecker/Test/SerialKeyCheckerControllerTest.php:12

When i force Patchwork version to be 1.4.0 in composer.json, everything seems fine.

Local test setup

My test setup is basically the following. I call it using a phpunit.xml and phpunit command.

Unit-Test:

use Brain\Monkey;

class UnitTestCase extends \PHPUnit_Framework_TestCase
{
    protected $fixture;

    public function setUp()
    {
        Monkey::setUpWP();
    }

    public function tearDown()
    {
        Monkey::tearDownWP();
    }
}

Test-Case:

class SerialKeyCheckerControllerTest extends UnitTestCase
{
    public function setUp()
    {
        parent::setUp();
    }

    /*
     * Tests for __construct()
     */

    public function testConstructor()
    {

    }
}

composer.json:

{
    "require-dev": {
        "brain/monkey": "1.*",
        "phpunit/phpunit": "*"
    }
}
@k00ni k00ni changed the title Error: Please import Patchwork from a point in your code where no user-defined function, class or trait is yet defined. Error: Please import Patchwork from a point in your code where no user-defined function, class or trait is yet defined. (BrainMonkey + PHPUnit) Feb 15, 2016
antecedent added a commit that referenced this issue Feb 22, 2016
@antecedent antecedent closed this May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.