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 26 of file TestUtil.php.

Static Public Member Functions

static initFramework ($configPath)
 
static createDatabase ()
 
static startServer ($documentRoot, $router='')
 
static simulateRequest ($request)
 
static startSession ($user, $password)
 
static endSession ()
 
static setConfigValue ($key, $value, $section)
 
static callProtectedMethod ($instance, $methodName, $args=null)
 
static getSizeof ($var)
 
static enableProfiler ($type)
 
static printProfile ($type)
 
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.'config.ini'
  • optional additional configuration in $configPath.'test.ini'
  • logging configuration in $configPath.'log.ini'
    Parameters
    $configPathThe path to the configuration directory

Definition at line 36 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 63 of file TestUtil.php.

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

Start the built-in webserver.

Parameters
$documentRootDocument root directory
$routerRouter script filename (optional)

Definition at line 88 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 134 of file TestUtil.php.

static startSession (   $user,
  $password 
)
static

Start a session.

This is usefull 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 153 of file TestUtil.php.

static endSession ( )
static

End a session.

Definition at line 170 of file TestUtil.php.

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

Set a configuration value.

See also
Configuration::setValue()

Definition at line 180 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 191 of file TestUtil.php.

static getSizeof (   $var)
static

Definition at line 205 of file TestUtil.php.

static enableProfiler (   $type)
static

Enable the Zend_Db_Profiler for a given entity type.

Parameters
$typeThe entity type

Definition at line 215 of file TestUtil.php.

static printProfile (   $type)
static

Print the profile of the operations on a given entity type.

The profiler must have been enabled first

Parameters
$typeThe entity type

Definition at line 227 of file TestUtil.php.

static isWindows ( )
static

Definition at line 254 of file TestUtil.php.