PHP Class think\PhpunitHelper

Show file Open project: snowair/phpunithelper-thinkphp Class Usage Examples

Protected Properties

Property Type Description
$_map
$action_name
$model Model
$testConfig

Public Methods

Method Description
__construct ( string $app_path = null, string $think_path = null, string $runtime_path = null )
addMap ( $class, string $map = '' ) 无需手动调用
autoload ( $class ) 启动加载器,已注册,无需手动调用
defineConst ( $name, $value ) 定义单个常量
defineConsts ( array $map ) 批量定义常量
fatalError ( )
getModel ( ) : Model 返回默认模型
getProjectRoot ( $vendorParent )
guessPath ( )
setActionName ( $action ) 设定控制器名称
setGET ( $get ) 设置 $_GET 变量
setMVC ( $http_host, $module_name, $controller_name, string $request_scheme = 'http', string $server_port = '80' ) 模拟常规的mvc应用
setPOST ( $post ) 设置 $_POST变量
setRequest ( $request, $merge_post = true ) 设置 $_POST变量
setServerEnv ( $name, $value ) 设置单个 $_SERVER 环境变量
setServerEnvs ( array $map ) 批量设置 $_SERVER 环境变量
setTestConfig ( array $config ) 你可以直接在测试代码里设置用于覆盖默认配置的配置项 但必须在start方法之前调用才有效
start ( ) 启动模拟应用

Protected Methods

Method Description
dispatch ( )
init ( )
loadEnvConfig ( ) 如果composer安装了DotEnv,你可以使用.test.env文件配置
run ( )

Private Methods

Method Description
_defineConsts ( ) 定义核心常量

Method Details

__construct() public method

public __construct ( string $app_path = null, string $think_path = null, string $runtime_path = null )
$app_path string
$think_path string
$runtime_path string 不要与正式的runtime目录相同

addMap() public static method

无需手动调用
public static addMap ( $class, string $map = '' )
$class
$map string

autoload() public static method

启动加载器,已注册,无需手动调用
public static autoload ( $class )
$class

defineConst() public method

定义单个常量
public defineConst ( $name, $value )
$name
$value

defineConsts() public method

批量定义常量
public defineConsts ( array $map )
$map array

dispatch() protected method

protected dispatch ( )

fatalError() public static method

public static fatalError ( )

getModel() public method

返回默认模型
public getModel ( ) : Model
return Model

getProjectRoot() public method

public getProjectRoot ( $vendorParent )

guessPath() public method

public guessPath ( )

init() protected method

protected init ( )

loadEnvConfig() protected method

如果composer安装了DotEnv,你可以使用.test.env文件配置
protected loadEnvConfig ( )

run() protected method

protected run ( )

setActionName() public method

设定控制器名称
public setActionName ( $action )
$action

setGET() public method

设置 $_GET 变量
public setGET ( $get )
$get

setMVC() public method

模拟常规的mvc应用
public setMVC ( $http_host, $module_name, $controller_name, string $request_scheme = 'http', string $server_port = '80' )
$http_host
$module_name
$controller_name
$request_scheme string
$server_port string

setPOST() public method

设置 $_POST变量
public setPOST ( $post )
$post

setRequest() public method

设置 $_POST变量
public setRequest ( $request, $merge_post = true )
$request
$merge_post

setServerEnv() public method

设置单个 $_SERVER 环境变量
public setServerEnv ( $name, $value )
$name
$value

setServerEnvs() public method

批量设置 $_SERVER 环境变量
public setServerEnvs ( array $map )
$map array

setTestConfig() public method

你可以直接在测试代码里设置用于覆盖默认配置的配置项 但必须在start方法之前调用才有效
public setTestConfig ( array $config )
$config array

start() public method

启动模拟应用
public start ( )

Property Details

$_map protected static property

protected static $_map

$action_name protected property

protected $action_name

$model protected property

protected Model,Think $model
return Model

$testConfig protected property

protected $testConfig