0
我在測試中遇到了問題。所以,我有場景:如何驗證某個密鑰是否在Behat陣列中
Scenario: Teste la route /settlement/rank/types
Given I request "http:/localhost/admin"
Then the response should be JSON
And I should have code with value 200
And I should have error with value 0
And The response has a "aUser" property
And This property "aUser" is not empty
And The property "aUser" has the keys:
|id_user |login |first_name |last_name |email |id_company |enable |id_language |label_language |
現在FeatureContext是:
/**
* @Given /^The property "([^"]*)" has the keys:$/
*/
public function thePropertyHasTheKeys($aProperty, TableNode $table){
$data = json_decode($this->_response->getBody(true),true);
foreach($table as $value){
print_r($value['id_user']);
if(!in_array($value,$data['data'][$aProperty])){
throw new Exception("The property ".$value. " is not set\n");
}
}
}
在$data
我有這種形式的數組:
|id_user |login |first_name |last_name |email |id_company |enable |id_language |label_language |
所以我想在陣列比較$data
與數組0123',如果密鑰相同。
日Thnx安德魯。 ... – 2015-02-10 12:34:00