TestCase
extends TestCase
in package
Basic Horde test case helper.
Copyright 2009-2021 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Tags
Table of Contents
- getConfig() : mixed
- Helper method for loading test configuration from a file.
- getMockDependencies() : MockDependencies
- Create a MockDependencies instance from a class name to simplyfy creation of classes where all or most dependencies are mocked.
- getMockSkipConstructor() : mixed
- Useful shorthand if you are mocking a class with a private constructor
Methods
getConfig()
Helper method for loading test configuration from a file.
public
static getConfig(string $env[, string $path = null ][, array<string|int, mixed> $default = array() ]) : mixed
The configuration can be specified by an environment variable. If the variable content is a file name, the configuration is loaded from the file. Otherwise it's assumed to be a json encoded configuration hash. If the environment variable is not set, the method tries to load a conf.php file from the same directory as the test case.
Parameters
- $env : string
-
An environment variable name.
- $path : string = null
-
The path to use.
- $default : array<string|int, mixed> = array()
-
Some default values that are merged into the configuration if specified as a json hash.
Return values
mixed —The value of the configuration file's $conf variable, or null.
getMockDependencies()
Create a MockDependencies instance from a class name to simplyfy creation of classes where all or most dependencies are mocked.
public
getMockDependencies(string $class[, array<string|int, mixed> $overrides = [] ]) : MockDependencies
Parameters
- $class : string
-
The full name of the class
- $overrides : array<string|int, mixed> = []
-
Optional. Hashmap were the keys are the names of the parameters of the class and values are the instance to use. Every parameter not set here, will be automatically mocked instead
Tags
Return values
MockDependencies —The MockDependencies instance that can be used to create instances of the class
getMockSkipConstructor()
Useful shorthand if you are mocking a class with a private constructor
public
getMockSkipConstructor(mixed $className[, array<string|int, mixed> $methods = array() ][, array<string|int, mixed> $arguments = array() ][, mixed $mockClassName = '' ]) : mixed
Parameters
- $className : mixed
- $methods : array<string|int, mixed> = array()
- $arguments : array<string|int, mixed> = array()
- $mockClassName : mixed = ''