[ Index ]

PHP Cross Reference of Unnamed Project

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  testing_update_composer_dependencies();
  43  
  44  $output = null;
  45  exec('php --version', $output, $code);
  46  if ($code != 0) {
  47      phpunit_bootstrap_error(1, 'Can not execute \'php\' binary.');
  48  }
  49  
  50  chdir(__DIR__);
  51  $output = null;
  52  exec("php util.php --diag", $output, $code);
  53  if ($code == 0) {
  54      // everything is ready
  55  
  56  } else if ($code == PHPUNIT_EXITCODE_INSTALL) {
  57      passthru("php util.php --install", $code);
  58      if ($code != 0) {
  59          exit($code);
  60      }
  61  
  62  } else if ($code == PHPUNIT_EXITCODE_REINSTALL) {
  63      passthru("php util.php --drop", $code);
  64      passthru("php util.php --install", $code);
  65      if ($code != 0) {
  66          exit($code);
  67      }
  68  
  69  } else {
  70      echo implode("\n", $output)."\n";
  71      exit($code);
  72  }
  73  
  74  passthru("php util.php --buildconfig", $code);
  75  
  76  echo "\n";
  77  echo "PHPUnit test environment setup complete.\n";
  78  exit(0);


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1