source: moodle/trunk/fuentes/admin/tool/phpunit/cli/init.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 2.1 KB
Line 
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
25if (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.
31if (function_exists('opcache_reset')) {
32    opcache_reset();
33}
34
35define('IGNORE_COMPONENT_CACHE', true);
36
37require_once(__DIR__.'/../../../../lib/clilib.php');
38require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
39require_once(__DIR__.'/../../../../lib/testing/lib.php');
40
41echo "Initialising Moodle PHPUnit test environment...\n";
42
43$output = null;
44exec('php --version', $output, $code);
45if ($code != 0) {
46    phpunit_bootstrap_error(1, 'Can not execute \'php\' binary.');
47}
48
49chdir(__DIR__);
50$output = null;
51exec("php util.php --diag", $output, $code);
52if ($code == 0) {
53    // everything is ready
54
55} else if ($code == PHPUNIT_EXITCODE_INSTALL) {
56    passthru("php util.php --install", $code);
57    if ($code != 0) {
58        exit($code);
59    }
60
61} else if ($code == PHPUNIT_EXITCODE_REINSTALL) {
62    passthru("php util.php --drop", $code);
63    passthru("php util.php --install", $code);
64    if ($code != 0) {
65        exit($code);
66    }
67
68} else {
69    echo implode("\n", $output)."\n";
70    exit($code);
71}
72
73passthru("php util.php --buildconfig", $code);
74
75exit(0);
Note: See TracBrowser for help on using the repository browser.