0
我作曲:貝哈特+ Symfony2MockerExtension:會話客戶端容器中沒有訪問
"require-dev": {
"polishsymfonycommunity/symfony2-mocker-extension": "*",
"behat/gherkin" : "~2.2.9",
"behat/behat": "v2.4.6",
"behat/symfony2-extension": "*",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"phpunit/phpunit": "3.7.29"
},
我的特點:
Feature: Submitting contact request form
Scenario: Submitting the form
And CRM API is available
Then the contact request should be sent to the CRM
貝哈特的錯誤:
Feature: Submitting contact request form
Scenario: Submitting the form
And CRM API is available
Session has no access to client container
Then the contact request should be sent to the CRM
我已經添加getContainerBaseClass在mi app/AppKernel()
/**
* @return string
*/
protected function getContainerBaseClass()
{
if ('test' == $this->environment) {
return '\PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer';
}
return parent::getContainerBaseClass();
}
和新句子在我FeatureContext:
class GeeftyContext extends MinkContext
implements KernelAwareInterface, ServiceMockerAwareInterface
{
/**
* @var ServiceMocker $mocker
*/
private $mocker = null;
/**
* @param ServiceMocker $mocker
* @return null|void
*/
public function setServiceMocker(ServiceMocker $mocker)
{
$this->mocker = $mocker;
}
/**
* @Given /^CRM API is available$/
*/
public function crmApiIsAvailable()
{
$this->mocker->mockService(
'my_service',
'Acme\Bundle\My\ServiceClass'
)->shouldReceive('method')->once()->andReturn(true);
}
/**
* @Then /^the contact request should be sent to the CRM$/
*/
public function theContactRequestShouldBeSentToTheCrm()
{
throw new PendingException();
}
}