Skip to content

Commit

Permalink
MDL-58169 phpunit: Clear opcode cache before checking file
Browse files Browse the repository at this point in the history
In unit test, we write cache file often and
opcache might fail to detect changes. It will
be nice to invalidate opcode cache to ensure
we have the correct file_exists status
  • Loading branch information
Rajesh Taneja authored and danpoltawski committed Mar 14, 2017
1 parent e79a53e commit ff14679
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cache/tests/fixtures/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,20 @@ public function get_site_identifier() {
global $CFG;
return $CFG->wwwroot.'phpunit';
}

/**
* Checks if the configuration file exists.
*
* @return bool True if it exists
*/
public static function config_file_exists() {
// Allow for late static binding by using static.
$configfilepath = static::get_config_file_path();

// Invalidate opcode php cache, so we get correct status of file.
core_component::invalidate_opcode_php_cache($configfilepath);
return file_exists($configfilepath);
}
}

/**
Expand Down

0 comments on commit ff14679

Please sign in to comment.