2016-08-10 11 views
0

私はbehat 3.0.15を持っています。私はこの最初のBehatテストを作成するときにtutorialに従います。プログラムでBehatのステップを呼び出す方法は?警告:Behat Behat Definition Call Given :: __ construct()の引数2がありません

コード:

/** 
* @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

関連する問題