From ddffa9d6d344fcc5de7e979824bf9d4c3fb49e95 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Mon, 6 Oct 2014 17:31:15 +1300 Subject: [PATCH] MDL-47538 phpunit: fix invalid PHPUNIT_SEQUENCE_START constant --- lib/phpunit/classes/util.php | 10 ++++++++-- lib/testing/classes/util.php | 2 +- phpunit.xml.dist | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php index a7584dd8fd1..8c2727d83ec 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -467,7 +467,10 @@ class phpunit_util extends testing_util { $sequencestart = 100000 + mt_rand(0, 99) * 1000; $data = preg_replace('|.*|s', $suites, $data, 1); - $data = preg_replace('||s', $sequencestart, $data, 1); + $data = str_replace( + '', + '', + $data); $result = false; if (is_writable($CFG->dirroot)) { @@ -523,7 +526,10 @@ class phpunit_util extends testing_util { // Apply it to the file template $fcontents = str_replace('', $ctemplate, $ftemplate); - $fcontents = preg_replace('||s', $sequencestart, $fcontents, 1); + $fcontents = str_replace( + '', + '', + $fcontents); // fix link to schema $level = substr_count(str_replace('\\', '/', $cpath), '/') - substr_count(str_replace('\\', '/', $CFG->dirroot), '/'); diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index 1cc7e52b4c0..c6b560a9579 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -458,7 +458,7 @@ abstract class testing_util { // 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; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 853b4eef932..1ff48e8800e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,7 +20,7 @@ - +