[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/admin/tool/phpunit/cli/ -> init.php (source)

   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  echo "Initialising Moodle PHPUnit test environment...\n";
  42  
  43  $output = null;
  44  exec('php --version', $output, $code);
  45  if ($code != 0) {
  46      phpunit_bootstrap_error(1, 'Can not execute \'php\' binary.');
  47  }
  48  
  49  chdir(__DIR__);
  50  $output = null;
  51  exec("php util.php --diag", $output, $code);
  52  if ($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  
  73  passthru("php util.php --buildconfig", $code);
  74  
  75  exit(0);


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1