Hub 20xx
Hub 20xx

Reputation: 461

behat / mink: using phpunit mock in context

I cannot find a way to use a phpunit mock in a behat context.

My FeatureContext cannot extend PHPUnit_Framework_TestCase because it already extends MinkContext.

I tried to have it implement PHPUnit_Framework_MockObject_MockObject but I got the fatal error that it should implement the 5 abstract methods.

I tried with the static call to PHPUnit_Framework_TestCase inside a FeatureContext method (where I need the mock) but then I got this error Non-static method PHPUnit_Framework_TestCase::getMockBuilder() should not be called statically, assuming $this from incompatible context in features/bootstrap/FeatureContext.php.

Any idea how I could achieve this?

Upvotes: 2

Views: 1976

Answers (1)

gontrollez
gontrollez

Reputation: 6538

Here is another question where it looks like it's explained what you need.

For mocking dependencies for Behat I prefer using Mockery. It's an independent library so the usage is the same from PHPUnit or Behat.

Upvotes: 2

Related Questions