MDL-46193 phpunit: Use random starting value on initialization.

This commit is contained in:
Russell Smith
2014-07-04 16:33:13 +10:00
parent 4de51c25ae
commit 529495f7ce
3 changed files with 11 additions and 1 deletions
+5
View File
@@ -461,8 +461,13 @@ class phpunit_util extends testing_util {
$suites .= $suite;
}
}
// Start a sequence between 100000 and 199000 to ensure each call to init produces
// different ids in the database. This reduces the risk that hard coded values will
// end up being placed in phpunit or behat test code.
$sequencestart = 100000 + mt_rand(0, 99) * 1000;
$data = preg_replace('|<!--@plugin_suites_start@-->.*<!--@plugin_suites_end@-->|s', $suites, $data, 1);
$data = preg_replace('|<!--@PHPUNIT_SEQUENCE_START@-->|s', $sequencestart, $data, 1);
$result = false;
if (is_writable($CFG->dirroot)) {