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:
@ -65,6 +65,7 @@ class ActiveFixture extends BaseActiveFixture
|
||||
/**
|
||||
* Loads the fixture.
|
||||
*
|
||||
* The default implementation will first clean up the table by calling [[resetTable()]].
|
||||
* It will then populate the table with the data returned by [[getData()]].
|
||||
*
|
||||
* If you override this method, you should consider calling the parent implementation
|
||||
@ -72,10 +73,9 @@ class ActiveFixture extends BaseActiveFixture
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
parent::load();
|
||||
|
||||
$this->resetTable();
|
||||
$this->data = [];
|
||||
$table = $this->getTableSchema();
|
||||
|
||||
foreach ($this->getData() as $alias => $row) {
|
||||
$this->db->createCommand()->insert($table->fullName, $row)->execute();
|
||||
if ($table->sequenceName !== null) {
|
||||
@ -90,17 +90,6 @@ class ActiveFixture extends BaseActiveFixture
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the fixture.
|
||||
*
|
||||
* The default implementation will clean up the table by calling [[resetTable()]].
|
||||
*/
|
||||
public function unload()
|
||||
{
|
||||
$this->resetTable();
|
||||
parent::unload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fixture data.
|
||||
*
|
||||
|
Reference in New Issue
Block a user