Permalink
Browse files

MDL-33550 reset repository static cache between unit tests

  • Loading branch information...
1 parent cfc4db4 commit 6fd1cf05b03834f0b9ec84941bb0f1ba383830dc @marinaglancy marinaglancy committed Jun 14, 2012
Showing with 17 additions and 4 deletions.
  1. +4 −1 lib/phpunit/classes/util.php
  2. +13 −3 repository/lib.php
@@ -612,8 +612,11 @@ public static function reset_all_data($logchanges = false) {
get_string_manager()->reset_caches();
events_get_handlers('reset');
textlib::reset_caches();
+ if (class_exists('repository')) {
+ repository::reset_caches();
+ }
$GROUPLIB_CACHE = null;
- //TODO: add more resets here and probably refactor them to new core function
+ //TODO MDL-25290: add more resets here and probably refactor them to new core function
// purge dataroot directory
self::reset_dataroot();
View
@@ -2191,21 +2191,31 @@ public function convert_references_to_local() {
}
}
-
+ /**
+ * Called from phpunit between tests, resets whatever was cached
+ */
+ public static function reset_caches() {
+ self::sync_external_file(null, true);
+ }
/**
* Call to request proxy file sync with repository source.
*
* @param stored_file $file
+ * @param bool $resetsynchistory whether to reset all history of sync (used by phpunit)
* @return bool success
*/
- public static function sync_external_file(stored_file $file) {
+ public static function sync_external_file($file, $resetsynchistory = false) {
global $DB;
+ // TODO MDL-25290 static should be replaced with MUC code.
static $synchronized = array();
+ if ($resetsynchistory) {
+ $synchronized = array();
+ }
$fs = get_file_storage();
- if (!$file->get_referencefileid()) {
+ if (!$file || !$file->get_referencefileid()) {
return false;
}
if (array_key_exists($file->get_id(), $synchronized)) {

0 comments on commit 6fd1cf0

Please sign in to comment.