2016-08-10 3 views
0

첫 번째 Behat 테스트를 만들 때 behat 3.0.15가 있고이 다음의 tutorial입니다.Behat 단계를 프로그래밍 방식으로 호출하는 방법은 무엇입니까? 경고 : Behat Behat Definition Call Given에 대한 인수 2가 누락되었습니다. __ construct()

코드 :

/** 
* @When I go to see akaneo product page for :country written in :language language    
*/ 
public function findOrCreateProductForCountryAndVisitIt($country, $language) 
{ 
    global $user; 
    $node = new stdClass; 
    $node->title = 'Test Product'; 
    $node->type = 'akaneo_product'; 
    node_object_prepare($node); 
    $node->uid = $user->uid; 
    $node->status = 1; 
    $node->language = $language; 
    #load domain id for country 
    $result = db_select('domain', 'd') 
     ->fields('d', array('domain_id')) 
     ->condition('subdomain', strtolower($country) . '_schiller.%', 'LIKE') 
     ->execute() 
     ->fetchAssoc(); 



    if (empty($result)) { 
     throw new Exception("Cannot find subsidiary for country code: $country"); 
    } 

    $node->domains = array(
     $result['domain_id'] => $result['domain_id'] 
    ); 

    $node = $this->nodeCreate($node); 

    return new Given('I go to node/' . $node->nid); 

} 

출력 : 나뿐만 호출 생성자의 매개 변수를 전달해야합니까

Warning: Missing argument 2 for Behat\Behat\Definition\Call\Given::__construct(), called in features/bootstrap/FeatureContext.php on line 435 and defined in vendor/behat/behat/src/Behat/Behat/Definition/Call/Given.php line 27 
│ 
╳ Unable to access the response content before visiting a page (Behat\Mink\Exception\DriverException) 
│ 
└─ @AfterStep # ScreenshotContext::logResponseAfterFailedStep() 

?

+0

어떻게 단계가 생겼 :

현재 제거에 대한 설명을 찾을 것인가? 코드를 추가 할 수 있습니까? – lauda

+0

추가 코드 – drupality

답변

1

Behat 3에서는 체인화 단계를 수행 할 수 없습니다. 일부 코드를 재사용하려면 일반 OOP 방식을 따르십시오. - 공통 코드를 별도의 메소드 또는 클래스로 추출하십시오. https://github.com/Behat/Behat/issues/546#issuecomment-45202991

+0

그래서 사용자 정의 단계에서 작성된 컨텐츠의 ID를 다른 단계로 전달할 방법이 없습니까? – drupality

+0

이 ID를 매개 변수로 다른 메소드에 전달할 수 있습니다. –

+0

정확히 :) 감사합니다. – drupality

관련 문제