PHP容器化demo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

69 lines
1.5 KiB

<?php
/**
* TestBase.php
* Test Base controller.
* @version 150629:1
* @author karminski <code.karminski@outlook.com>
*
*/
/**
* abstract class TestBase
*/
abstract class TestBase{
public $_log;
/**
* [__construct description]
*/
public function __construct($requirements){
// require
$this->InitRequirements($requirements);
// check mode
if(ONLINE_MODE){
$debug = false;
}else{
$debug = true;
}
// load files
$this->initLog($debug);
$this->debugSwitch(true);
}
/**
* [debugSwitch description]
* @param boolean $switch [description]
* @return [type] [description]
*/
public function debugSwitch($switch = false){
if($switch){
ini_set('display_errors', 1);
error_reporting(E_ALL);
}
return;
}
/**
* [InitRequirements description]
*/
public function InitRequirements($requirements){
$class_name = get_class($this);
require(dirname(__FILE__).'/../protected/lib/base/AutoRequire.php');
AutoRequire::_class($requirements);
return;
}
/**
* [initLog description]
* @param [type] $debug [description]
* @return [type] [description]
*/
public function initLog($debug){
$this->_log = new Log();
$this->_log->setLogAddress(LOG_FILE, LOG_SPLIT);
$this->_log->setEchoSwitch($debug);
return;
}
}