Use PHP Unit with Composer whenever possible. Fixes #60
authorFrederic Massart <fmcell@gmail.com>
Fri, 13 Dec 2013 07:15:44 +0000 (08:15 +0100)
committerFrederic Massart <fmcell@gmail.com>
Fri, 13 Dec 2013 07:15:44 +0000 (08:15 +0100)
lib/commands/phpunit.py

index 7da728d..aaf25a8 100644 (file)
@@ -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')