Skip to content

Commit

Permalink
MDL-47538 phpunit: fix invalid PHPUNIT_SEQUENCE_START constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Skoda committed Oct 6, 2014
1 parent 6597413 commit ddffa9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/phpunit/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ public static function build_config_file() {
$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);
$data = str_replace(
'<const name="PHPUNIT_SEQUENCE_START" value=""/>',
'<const name="PHPUNIT_SEQUENCE_START" value="' . $sequencestart . '"/>',
$data);

$result = false;
if (is_writable($CFG->dirroot)) {
Expand Down Expand Up @@ -523,7 +526,10 @@ public static function build_component_config_files() {

// Apply it to the file template
$fcontents = str_replace('<!--@component_suite@-->', $ctemplate, $ftemplate);
$fcontents = preg_replace('|<!--@PHPUNIT_SEQUENCE_START@-->|s', $sequencestart, $fcontents, 1);
$fcontents = str_replace(
'<const name="PHPUNIT_SEQUENCE_START" value=""/>',
'<const name="PHPUNIT_SEQUENCE_START" value="' . $sequencestart . '"/>',
$fcontents);

// fix link to schema
$level = substr_count(str_replace('\\', '/', $cpath), '/') - substr_count(str_replace('\\', '/', $CFG->dirroot), '/');
Expand Down
2 changes: 1 addition & 1 deletion lib/testing/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public static function reset_all_database_sequences(array $empties = null) {
// To reduce the chance of the coding error, we start sequences at different values where possible.
// In a attempt to avoid tables with existing id's we start at a high number.
// Reset the value each time all database sequences are reset.
if (defined('PHPUNIT_SEQUENCE_START')) {
if (defined('PHPUNIT_SEQUENCE_START') and PHPUNIT_SEQUENCE_START) {
self::$sequencenextstartingid = PHPUNIT_SEQUENCE_START;
} else {
self::$sequencenextstartingid = 100000;
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<php>
<!--<const name="PHPUNIT_LONGTEST" value="1"/> uncomment to execute also slow or otherwise expensive tests-->
<const name="PHPUNIT_SEQUENCE_START" value="<!--@PHPUNIT_SEQUENCE_START@-->"/>
<const name="PHPUNIT_SEQUENCE_START" value=""/>

<!--Following constants instruct tests to fetch external test files from alternative location or skip tests if empty, clone https://github.com/moodlehq/moodle-exttests to local web server-->
<!--<const name="TEST_EXTERNAL_FILES_HTTP_URL" value="http://download.moodle.org/unittest"/> uncomment and alter to fetch external test files from alternative location-->
Expand Down

0 comments on commit ddffa9d

Please sign in to comment.