Detailed Description

TestUtil provides helper methods for testing wCMF functionality.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

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

static initFramework (   $configPath)
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
    $configPathThe path to the configuration directory

Definition at line 35 of file TestUtil.php.

static createDatabase ( )
static

Create the test database, if sqlite is configured.

Returns
Associative array with connection parameters and key 'connection'

Definition at line 64 of file TestUtil.php.

static startServer (   $documentRoot,
  $router = '',
  $killOnExit = false 
)
static

Start the built-in webserver.

Parameters
$documentRootDocument root directory
$routerRouter script filename (optional)
$killOnExitBoolean, whether to kill the server process after script execution or not (optional, default: false)

Definition at line 99 of file TestUtil.php.

static simulateRequest (   $request)
static

Process a request as if it was sent to main.php.

Parameters
$requestThe Request instance
Returns
The Response instance (result of the last ActionMapper::processAction call)

Definition at line 151 of file TestUtil.php.

static startSession (   $user,
  $password 
)
static

Start a session.

This is useful for simulateRequest calls

Parameters
$userThe name of the user
$passwordThe 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.

static endSession ( )
static

End a session.

Definition at line 190 of file TestUtil.php.

static setConfigValue (   $key,
  $value,
  $section 
)
static

Set a configuration value.

See also
Configuration::setValue()

Definition at line 200 of file TestUtil.php.

static callProtectedMethod (   $instance,
  $methodName,
  $args = null 
)
static

Call a protected/private method of an instance (PHP >= 5.3.2)

Parameters
$instanceThe instance
$methodNameThe method name
$argsAn array of method arguments

Definition at line 211 of file TestUtil.php.

static getSizeof (   $var)
static

Definition at line 225 of file TestUtil.php.

static isWindows ( )
static

Definition at line 231 of file TestUtil.php.