Fixes #5176: ActiveFixture will reset table in its load() method instead of unload()

This commit is contained in:
Qiang Xue
2014-09-25 12:27:09 -04:00
parent 014aab1b9a
commit 205400f118
3 changed files with 8 additions and 28 deletions

View File

@ -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());