Skip to content

Commit

Permalink
Fixed issue #16692: Clear process after test script is failing
Browse files Browse the repository at this point in the history
Cache was not properly cleared in between tests neither after survey deletion
  • Loading branch information
gabrieljenik committed Oct 1, 2020
1 parent 6c4108e commit d99f229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions application/models/Survey.php
Expand Up @@ -297,6 +297,12 @@ public function delete($recursive=true)
// Delete all uploaded files.
rmdirr(Yii::app()->getConfig('uploaddir').'/surveys/'.$this->sid);
}

// Remove from cache
if (array_key_exists($this->sid, $this->findByPkCache)) {
unset $this->findByPkCache[$this->sid];
}

return true;
}

Expand Down
1 change: 1 addition & 0 deletions tests/TestBaseClass.php
Expand Up @@ -78,6 +78,7 @@ protected static function importSurvey($fileName)
null
);
if ($result) {
\Survey::model()->resetCache(); // Reset the cache so findByPk doesn't return a previously cached survey
self::$testSurvey = \Survey::model()->findByPk($result['newsid']);
self::$surveyId = $result['newsid'];
} else {
Expand Down

0 comments on commit d99f229

Please sign in to comment.