mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixes #5176: ActiveFixture
will reset table in its load()
method instead of unload()
This commit is contained in:
@ -53,12 +53,13 @@ class ActiveFixture extends BaseActiveFixture
|
||||
|
||||
/**
|
||||
* Loads the fixture data.
|
||||
* Data will be batch inserted into the given collection.
|
||||
* The default implementation will first reset the DB table and then populate it with the data
|
||||
* returned by [[getData()]].
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
parent::load();
|
||||
|
||||
$this->resetCollection();
|
||||
$this->data = [];
|
||||
$data = $this->getData();
|
||||
$this->getCollection()->batchInsert($data);
|
||||
foreach ($data as $alias => $row) {
|
||||
@ -66,17 +67,6 @@ class ActiveFixture extends BaseActiveFixture
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the fixture.
|
||||
*
|
||||
* The default implementation will clean up the collection by calling [[resetCollection()]].
|
||||
*/
|
||||
public function unload()
|
||||
{
|
||||
$this->resetCollection();
|
||||
parent::unload();
|
||||
}
|
||||
|
||||
protected function getCollection()
|
||||
{
|
||||
return $this->db->getCollection($this->getCollectionName());
|
||||
|
Reference in New Issue
Block a user