MDL-46193 phpunit: Replace value in component config.

There are two phpunit.xml build locations, one for overall
and another for individual components.  To reduce id changes
when running different components, we use the same initial ID
in all component files when building.
This commit is contained in:
Russell Smith 2014-07-09 17:47:19 +10:00 committed by Eloy Lafuente (stronk7)
parent 539a25ff03
commit 9462323b13

View File

@ -503,6 +503,11 @@ class phpunit_util extends testing_util {
</testsuite>
</testsuites>';
// 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;
// Use the upstream file as source for the distributed configurations
$ftemplate = file_get_contents("$CFG->dirroot/phpunit.xml.dist");
$ftemplate = preg_replace('|<!--All core suites.*</testsuites>|s', '<!--@component_suite@-->', $ftemplate);
@ -518,6 +523,7 @@ class phpunit_util extends testing_util {
// Apply it to the file template
$fcontents = str_replace('<!--@component_suite@-->', $ctemplate, $ftemplate);
$fcontents = preg_replace('|<!--@PHPUNIT_SEQUENCE_START@-->|s', $sequencestart, $fcontents, 1);
// fix link to schema
$level = substr_count(str_replace('\\', '/', $cpath), '/') - substr_count(str_replace('\\', '/', $CFG->dirroot), '/');