MDL-52605 phpunit: Check file only if needed

This commit is contained in:
Rajesh Taneja
2016-01-04 07:59:25 +08:00
parent 8d94e92599
commit 91d5491ee2
+16 -20
View File
@@ -263,17 +263,15 @@ abstract class testing_util {
* @return array $table=>$records
*/
protected static function get_tabledata() {
global $CFG;
$framework = self::get_framework();
$datafile = self::get_dataroot() . '/' . $framework . '/tabledata.ser';
if (!file_exists($datafile)) {
// Not initialised yet.
return array();
}
if (!isset(self::$tabledata)) {
$framework = self::get_framework();
$datafile = self::get_dataroot() . '/' . $framework . '/tabledata.ser';
if (!file_exists($datafile)) {
// Not initialised yet.
return array();
}
$data = file_get_contents($datafile);
self::$tabledata = unserialize($data);
}
@@ -291,17 +289,15 @@ abstract class testing_util {
* @return array $table=>$records
*/
public static function get_tablestructure() {
global $CFG;
$framework = self::get_framework();
$structurefile = self::get_dataroot() . '/' . $framework . '/tablestructure.ser';
if (!file_exists($structurefile)) {
// Not initialised yet.
return array();
}
if (!isset(self::$tablestructure)) {
$framework = self::get_framework();
$structurefile = self::get_dataroot() . '/' . $framework . '/tablestructure.ser';
if (!file_exists($structurefile)) {
// Not initialised yet.
return array();
}
$data = file_get_contents($structurefile);
self::$tablestructure = unserialize($data);
}