Имам следната функция:
Scenario: Product page
Given there are the following products:
| id | name | price |
| 1 | Test product | 100 |
When I am on "/product/view/1"
Then the main page title should be "Test product"
Сега използвам Symfony с Doctrine. Така че в моя контекст клас не мога да направя това:
/**
* @Given /^there are the following products:$/
*/
public function createProducts(TableNode $products)
{
$hash = $users->getHash();
foreach ($hash as $row) {
// Create our user and set details
$product = new Product();
$product->setId($row['id']); // <= This method doesn't exist
$product->setName($row['name']);
$product->setPrice($row['price']);
// Persist product...
}
}
Методът setId не съществува и не изглежда добра идея да се създава. Та въпросът ми е има ли някакъв начин да тествам това?