From 668001615334e1fa1c390a8ba31ed3ca9fbbc73e Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 13 Dec 2013 08:15:44 +0100 Subject: [PATCH] Use PHP Unit with Composer whenever possible. Fixes #60 --- lib/commands/phpunit.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/commands/phpunit.py b/lib/commands/phpunit.py index 7da728d..aaf25a8 100644 --- a/lib/commands/phpunit.py +++ b/lib/commands/phpunit.py @@ -90,8 +90,11 @@ class PhpunitCommand(Command): if args.testcase and M.branch_compare('26', '<'): self.argumentError('The --testcase option only works with Moodle 2.6 or greater.') - # Install Composer for >= 2.5 - if M.branch_compare(25): + # Composer was introduced with PHP Unit, if the JSON file is there then we will use it + hasComposer = os.path.isfile(os.path.join(M.get('path'), 'composer.json')) + + # Install Composer + if hasComposer: if not os.path.isfile(os.path.join(M.get('path'), 'composer.phar')): logging.info('Installing Composer') cliFile = 'phpunit_install_composer.php' @@ -118,7 +121,7 @@ class PhpunitCommand(Command): if args.run: cmd = [] - if M.branch_compare(25): + if hasComposer: cmd.append('vendor/bin/phpunit') else: cmd.append('phpunit') -- 2.11.0