/**
  * Request to Controller
  *
  * @param string       $http_method HTTP method
  * @param array|string $argv        array of controller,method,arg|uri
  * @param array|string $params      POST params/GET params|raw_input_stream
  */
 public function request($http_method, $argv, $params = [])
 {
     if (is_string($argv)) {
         $argv = ltrim($argv, '/');
     }
     // Set super globals
     $_SERVER['REQUEST_METHOD'] = $http_method;
     $this->superGlobal->set_GET($argv, $params);
     $this->superGlobal->set_POST($params);
     $this->superGlobal->set_SERVER_REQUEST_URI($argv);
     try {
         if (is_array($argv)) {
             return $this->callControllerMethod($http_method, $argv, $params);
         } else {
             return $this->requestUri($http_method, $argv, $params);
         }
     } catch (CIPHPUnitTestRedirectException $e) {
         if ($e->getCode() === 0) {
             set_status_header(200);
         } else {
             set_status_header($e->getCode());
         }
         $CI =& get_instance();
         $CI->output->_status['redirect'] = $e->getMessage();
     } catch (CIPHPUnitTestShow404Exception $e) {
         $this->processError($e);
         return $e->getMessage();
     } catch (CIPHPUnitTestShowErrorException $e) {
         $this->processError($e);
         return $e->getMessage();
     }
 }
Beispiel #2
0
/**
 * Reset CodeIgniter instance
 */
function reset_instance()
{
    // Reset loaded classes
    load_class('', '', NULL, TRUE);
    is_loaded('', TRUE);
    // Reset config functions
    reset_config();
    // Close db connection
    $CI =& get_instance();
    if (isset($CI->db)) {
        if ($CI->db->dsn !== 'sqlite::memory:' && $CI->db->database !== ':memory:') {
            $CI->db->close();
            $CI->db = null;
        } else {
            // Don't close if SQLite in-memory database
            // If we close it, all tables and stored data will be gone
            load_class_instance('db', $CI->db);
        }
    }
    // Load core classes
    $BM =& load_class('Benchmark', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('BM', $BM);
    $EXT =& load_class('Hooks', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('EXT', $EXT);
    $CFG =& load_class('Config', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('CFG', $CFG);
    $UNI =& load_class('URI', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('UNI', $UNI);
    //	$URI =& load_class('Utf8', 'core');
    //	CIPHPUnitTestSuperGlobal::set_Global('URI', $URI);
    $RTR =& load_class('Router', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('RTR', $RTR);
    $OUT =& load_class('Output', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('OUT', $OUT);
    $SEC =& load_class('Security', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC);
    $IN =& load_class('Input', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('IN', $IN);
    $LANG =& load_class('Lang', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG);
    CIPHPUnitTest::loadLoader();
    // Remove CodeIgniter instance
    $CI = new CIPHPUnitTestNullCodeIgniter();
}
$SEC =& load_class('Security', 'core');
CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC);
/*
 * ------------------------------------------------------
 *  Load the Input class and sanitize globals
 * ------------------------------------------------------
 */
$IN =& load_class('Input', 'core');
CIPHPUnitTestSuperGlobal::set_Global('IN', $IN);
/*
 * ------------------------------------------------------
 *  Load the Language class
 * ------------------------------------------------------
 */
$LANG =& load_class('Lang', 'core');
CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG);
/*
 * ------------------------------------------------------
 *  Load the app controller and local controller
 * ------------------------------------------------------
 *
 */
// Load the base controller class
require_once BASEPATH . 'core/Controller.php';
/**
 * Reference to the CI_Controller method.
 *
 * Returns current CI instance object
 *
 * @return object
 *