Skip to content

Commit

Permalink
Fixed issue #16714: Clear process after test script is failing (#1614)
Browse files Browse the repository at this point in the history
Clear cache after test ends and also after a survye is deleted
  • Loading branch information
gabrieljenik committed Oct 12, 2020
1 parent ee7a208 commit 3f9b19f
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 @@ -335,6 +335,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 @@ -80,6 +80,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 3f9b19f

Please sign in to comment.