import gzip
import urllib
from ..command import Command
-from ..tools import process
+from ..tools import process, question
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:
return headcommit
- def initPHPUnit(self, force=False):
+ def initPHPUnit(self, force=False, prefix=None):
"""Initialise the PHPUnit environment"""
if self.branch_compare(23, '<'):
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