From faf3e03c6ebe4911b4868b133e089a22e50bc272 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Tue, 7 Jan 2014 15:19:38 +0100 Subject: [PATCH] Make behat command compatible with Moodle 2.7-dev --- config-dist.json | 9 +++++++++ lib/commands/behat.py | 7 ++++--- lib/moodle.py | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/config-dist.json b/config-dist.json index 417aa94..1eee99f 100644 --- a/config-dist.json +++ b/config-dist.json @@ -144,6 +144,15 @@ // What to call the upstream remote, the one pointing to the official repositoriy (stable or integration) "upstreamRemote": "origin", + // Behat related settings + "behat": { + + // From 2.7 Behat requires a different wwwroot than the one set in config.php. + // MDK assumes that the only thing that will differ between the wwwroot and + // behat wwwroot is the host, nothing else. Use a ServerAlias or /etc/hosts entries. + "host": "127.0.0.1" + }, + // The name of the data directory "dataDir": "moodledata", // The name of the www directory diff --git a/lib/commands/behat.py b/lib/commands/behat.py index 877c179..21a0227 100644 --- a/lib/commands/behat.py +++ b/lib/commands/behat.py @@ -46,7 +46,7 @@ class BehatCommand(Command): ['-d', '--disable'], { 'action': 'store_true', - 'help': 'disable Behat, runs the tests first if --run has been set.' + 'help': 'disable Behat, runs the tests first if --run has been set. Ignored from 2.7.' } ), ( @@ -84,7 +84,7 @@ class BehatCommand(Command): { 'action': 'store_true', 'dest': 'switchcompletely', - 'help': 'force the switch completely setting. This will be automatically enabled for PHP < 5.4' + 'help': 'force the switch completely setting. This will be automatically enabled for PHP < 5.4. Ignored from 2.7.' } ), ( @@ -266,7 +266,8 @@ class BehatCommand(Command): self.disable(M) else: - logging.info('Launch PHP Server (or set $CFG->behat_switchcompletely to True):\n %s' % (phpCommand)) + if M.branch_compare(27, '<'): + logging.info('Launch PHP Server (or set $CFG->behat_switchcompletely to True):\n %s' % (phpCommand)) if seleniumCommand: logging.info('Launch Selenium (optional):\n %s' % (seleniumCommand)) logging.info('Launch Behat:\n %s' % (cmd)) diff --git a/lib/moodle.py b/lib/moodle.py index 30a6bf0..db005d1 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -333,12 +333,20 @@ class Moodle(object): self.updateConfig('behat_prefix', behat_prefix) # Switch completely? - if switchcompletely: - self.updateConfig('behat_switchcompletely', switchcompletely) - self.updateConfig('behat_wwwroot', self.get('wwwroot')) + if self.branch_compare(27, '<'): + if switchcompletely: + self.updateConfig('behat_switchcompletely', switchcompletely) + self.updateConfig('behat_wwwroot', self.get('wwwroot')) + else: + self.removeConfig('behat_switchcompletely') + self.removeConfig('behat_wwwroot') else: - self.removeConfig('behat_switchcompletely') - self.removeConfig('behat_wwwroot') + # Defining wwwroot. + wwwroot = '%s://%s/' % (C.get('scheme'), C.get('behat.host')) + if C.get('path') != '' and C.get('path') != None: + wwwroot = wwwroot + C.get('path') + '/' + wwwroot = wwwroot + self.identifier + self.updateConfig('behat_wwwroot', wwwroot) # Force a cache purge self.purge() -- 2.11.0