Detailed Description
TestUtil provides helper methods for testing wCMF functionality.
Definition at line 25 of file TestUtil.php.
Static Public Member Functions | |
static | initFramework ($configPath) |
static | createDatabase () |
static | startServer ($documentRoot, $router='', $killOnExit=false) |
static | simulateRequest ($request) |
static | startSession ($user, $password) |
static | endSession () |
static | setConfigValue ($key, $value, $section) |
static | callProtectedMethod ($instance, $methodName, $args=null) |
static | getSizeof ($var) |
static | isWindows () |
Member Function Documentation
◆ initFramework()
|
static |
Set up the wcmf framework.
The method makes the following assumptions about file locations:
- main configuration in $configPath.'backend.ini'
- optional additional configuration in $configPath.'test.ini'
- logging configuration in $configPath.'log.ini'
- Parameters
-
$configPath The path to the configuration directory
Definition at line 35 of file TestUtil.php.
◆ createDatabase()
|
static |
Create the test database, if sqlite is configured.
- Returns
- Associative array with connection parameters and key 'connection'
Definition at line 65 of file TestUtil.php.
◆ startServer()
|
static |
Start the built-in webserver that serves the application under test.
- Parameters
-
$documentRoot Document root directory $router Router script filename (optional) $killOnExit Boolean, whether to kill the server process after script execution or not (optional, default: false)
Definition at line 100 of file TestUtil.php.
◆ simulateRequest()
|
static |
Process a request as if it was sent to main.php.
- Parameters
-
$request The Request instance
- Returns
- The Response instance (result of the last ActionMapper::processAction call)
Definition at line 151 of file TestUtil.php.
◆ startSession()
|
static |
Start a session.
This is useful for simulateRequest calls
- Parameters
-
$user The name of the user $password The password of the user
- Returns
- The session id. Use this as data['sid'] parameter for subsequent simulateRequest calls
Definition at line 170 of file TestUtil.php.
◆ endSession()
|
static |
End a session.
Definition at line 190 of file TestUtil.php.
◆ setConfigValue()
|
static |
Set a configuration value.
- See also
- Configuration::setValue()
Definition at line 200 of file TestUtil.php.
◆ callProtectedMethod()
|
static |
Call a protected/private method of an instance (PHP >= 5.3.2)
- Parameters
-
$instance The instance $methodName The method name $args An array of method arguments
Definition at line 211 of file TestUtil.php.
◆ getSizeof()
|
static |
Definition at line 225 of file TestUtil.php.
◆ isWindows()
|
static |
Definition at line 231 of file TestUtil.php.