2012-08-06 96 views
0

我很熟悉貂皮帽,等等,所以我需要幫助。爲水貂創建步驟

我有一個表有一些行,我想檢查一行是否被刪除。

在我的情況我已經是這樣的:

When I press "Delete" 
Then I should be on "/example_url/" 
    And I should see "Object list" 
    And the response should not contain "Value1" "Value2" "Value3" "Value4" 

我如何做到這一點?我該怎麼做「答案不應該包含一行的某些值」?

我不知道這可能與貂或我需要使用酉測試。

+0

我刪除了'Symfony'標籤,因爲它沒有太多處理 – 2012-08-06 15:15:13

回答

1

你可以在你的步驟使用tables

And the result table should not contain: 
    |Value | 
    |Value1| 
    |Value2| 
    |Value3| 
    |Value4| 

貝哈特將它傳遞給你的步法作爲TableNode實例:

/** 
* @Given /the result table should not contain:/ 
*/ 
public function thePeopleExist(TableNode $table) 
{ 
    $hash = $table->getHash(); 
    foreach ($hash as $row) { 
     // ... 
    } 
} 

在小黃瓜語言閱讀更多的寫作特點:http://docs.behat.org/guides/1.gherkin.html

Digression:請注意,大部分時間使用Mink ste直接在你的功能ps不是最好的主意,因爲大部分時間它不是你的業務語言。如果你寫你的情況是更具可讀性和可維護性:

When I press "Delete" 
Then I should be on the user page 
And I should see a list of users 
And the following users should be deleted: 
    |Name | 
    |Biruwon| 
    |Kuba | 
    |Anna | 

在你實施步驟,你可以通過返回然後情況下使用默認的水貂步驟:

/** 
* @Given /^I should see a list of users$/ 
*/ 
public function iShouldSeeListOfUsers() 
{ 
    return new Then('I should see "User list"'); 
}