代码接收。插入多条记录
Codeception. Insert multiple records
在Codeception中是否可以向数据库中插入多条记录?此代码不起作用,但也许还有其他选择。
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 1"],
['destination' => $this->"Place 2"]);
将其一分为二效果很好。
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 1"]);
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 2"]);
使用foreach?我会这样做:
$places = ["Place 1", "Place 2"];
foreach ($places as $place) {
$this->tester->haveRecord('vacations', ['destination' => $place]);
}
在Codeception中是否可以向数据库中插入多条记录?此代码不起作用,但也许还有其他选择。
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 1"],
['destination' => $this->"Place 2"]);
将其一分为二效果很好。
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 1"]);
$this->tester->haveRecord('vacations',
['destination' => $this->"Place 2"]);
使用foreach?我会这样做:
$places = ["Place 1", "Place 2"];
foreach ($places as $place) {
$this->tester->haveRecord('vacations', ['destination' => $place]);
}