See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * All in one init script - PHP version. 19 * 20 * @package tool_phpunit 21 * @copyright 2012 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 if (isset($_SERVER['REMOTE_ADDR'])) { 26 die; // no access from web! 27 } 28 29 // Force OPcache reset if used, we do not want any stale caches 30 // when preparing test environment. 31 if (function_exists('opcache_reset')) { 32 opcache_reset(); 33 } 34 35 define('IGNORE_COMPONENT_CACHE', true); 36 37 require_once (__DIR__.'/../../../../lib/clilib.php'); 38 require_once (__DIR__.'/../../../../lib/phpunit/bootstraplib.php'); 39 require_once (__DIR__.'/../../../../lib/testing/lib.php'); 40 41 list($options, $unrecognized) = cli_get_params( 42 [ 43 'help' => false, 44 'disable-composer' => false, 45 'composer-upgrade' => true, 46 'composer-self-update' => true, 47 ], 48 [ 49 'h' => 'help', 50 ] 51 ); 52 53 $help = " 54 Utilities to initialise the PHPUnit test site. 55 56 Usage: 57 php init.php [--no-composer-self-update] [--no-composer-upgrade] 58 [--help] 59 60 --no-composer-self-update 61 Prevent upgrade of the composer utility using its self-update command 62 63 --no-composer-upgrade 64 Prevent update development dependencies using composer 65 66 --disable-composer 67 A shortcut to disable composer self-update and dependency update 68 Note: Installation of composer and/or dependencies will still happen as required 69 70 -h, --help Print out this help 71 72 Example from Moodle root directory: 73 \$ php admin/tool/phpunit/cli/init.php 74 "; 75 76 if (!empty($options['help'])) { 77 echo $help; 78 exit(0); 79 } 80 81 echo "Initialising Moodle PHPUnit test environment...\n"; 82 83 if ($options['disable-composer']) { 84 // Disable self-update and upgrade easily. 85 // Note: Installation will still occur regardless of this setting. 86 $options['composer-self-update'] = false; 87 $options['composer-upgrade'] = false; 88 } 89 90 // Install and update composer and dependencies as required. 91 testing_update_composer_dependencies($options['composer-self-update'], $options['composer-upgrade']); 92 93 $output = null; 94 exec('php --version', $output, $code); 95 if ($code != 0) { 96 phpunit_bootstrap_error(1, 'Can not execute \'php\' binary.'); 97 } 98 99 chdir(__DIR__); 100 $output = null; 101 exec("php util.php --diag", $output, $code); 102 if ($code == 0) { 103 // everything is ready 104 105 } else if ($code == PHPUNIT_EXITCODE_INSTALL) { 106 passthru("php util.php --install", $code); 107 if ($code != 0) { 108 exit($code); 109 } 110 111 } else if ($code == PHPUNIT_EXITCODE_REINSTALL) { 112 passthru("php util.php --drop", $code); 113 passthru("php util.php --install", $code); 114 if ($code != 0) { 115 exit($code); 116 } 117 118 } else { 119 echo implode("\n", $output)."\n"; 120 exit($code); 121 } 122 123 passthru("php util.php --buildconfig", $code); 124 125 echo "\n"; 126 echo "PHPUnit test environment setup complete.\n"; 127 exit(0);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body