From 5b7244676cdca74f05ba0b406ea268ed96ab0f55 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 22 Oct 2014 13:37:35 +0800 Subject: [PATCH] PHPUnit can be initialised with Oracle --- mdk/commands/phpunit.py | 13 +++++++++++-- mdk/moodle.py | 13 ++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/mdk/commands/phpunit.py b/mdk/commands/phpunit.py index 5e7fdb3..3356890 100644 --- a/mdk/commands/phpunit.py +++ b/mdk/commands/phpunit.py @@ -27,7 +27,7 @@ import os import gzip import urllib from ..command import Command -from ..tools import process +from ..tools import process, question class PhpunitCommand(Command): @@ -121,7 +121,16 @@ class PhpunitCommand(Command): # Run cli try: - M.initPHPUnit(force=args.force) + + # If Oracle, ask the user for a Behat prefix, if not set. + prefix = M.get('phpunit_prefix') + if M.get('dbtype') == 'oci' and (args.force or not prefix or len(prefix) > 2): + while not prefix or len(prefix) > 2: + prefix = question('What prefix would you like to use? (Oracle, max 2 chars)') + else: + prefix = None + + M.initPHPUnit(force=args.force, prefix=prefix) logging.info('PHPUnit ready!') if args.unittest or args.testcase or args.filter: diff --git a/mdk/moodle.py b/mdk/moodle.py index 6970b7d..64cf6c3 100644 --- a/mdk/moodle.py +++ b/mdk/moodle.py @@ -281,7 +281,7 @@ class Moodle(object): return headcommit - def initPHPUnit(self, force=False): + def initPHPUnit(self, force=False, prefix=None): """Initialise the PHPUnit environment""" if self.branch_compare(23, '<'): @@ -294,8 +294,15 @@ class Moodle(object): mkdir(phpunit_dataroot, 0777) # Set PHPUnit prefix - phpunit_prefix = 'phpu_' - self.updateConfig('phpunit_prefix', phpunit_prefix) + currentPrefix = self.get('phpunit_prefix') + phpunit_prefix = prefix or 'phpu_' + + if not currentPrefix or force: + self.updateConfig('phpunit_prefix', phpunit_prefix) + elif currentPrefix != phpunit_prefix and self.get('dbtype') != 'oci': + # Warn that a prefix is already set and we did not change it. + # No warning for Oracle as we need to set it to something else. + logging.warning('PHPUnit prefix not changed, already set to \'%s\', expected \'%s\'.' % (currentPrefix, phpunit_prefix)) result = (None, None, None) exception = None -- 2.11.0