From 41bb7608e83da736d91039ad4dcf24f6cced097c Mon Sep 17 00:00:00 2001 From: Jason Platts Date: Fri, 29 Mar 2019 14:36:19 +0000 Subject: [PATCH] MDL-65220 behat: test scenarios sometimes do not clear database data --- lib/testing/classes/util.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index 176700bb286..737c7532472 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -926,12 +926,11 @@ abstract class testing_util { if (defined('BEHAT_SITE_RUNNING')) { $tablesupdatedfile = self::get_tables_updated_by_scenario_list_path(); - if ($tablesupdated = @json_decode(file_get_contents($tablesupdatedfile), true)) { - $tablesupdated[$table] = true; - } else { + $tablesupdated = @json_decode(file_get_contents($tablesupdatedfile), true); + if (!isset($tablesupdated[$table])) { $tablesupdated[$table] = true; + @file_put_contents($tablesupdatedfile, json_encode($tablesupdated, JSON_PRETTY_PRINT)); } - @file_put_contents($tablesupdatedfile, json_encode($tablesupdated, JSON_PRETTY_PRINT)); } } }