\Dewdrop\Test\AdminHelper

This helper is used by all admin test case classes to provide the ability to easily get access to the tested component object and dispatch pages from it. This is used to allow some "horizontal" reuse between the admin test cases because we can't achieve the reuse with inheritance. PHPUnit has a pre-defined hierarchy imposed by its DBUnit extension, so we need to compose our additional functionality in this manner.

Summary

Methods
Properties
Constants
__construct()
setMockResponseHelper()
dispatchPage()
getPage()
getResponseHelper()
getComponent()
getDb()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
createRequest()
$db
$testCase
$componentFolder
$componentNamespace
$mockResponseHelper
N/A

Properties

$db

$db : \Dewdrop\Db\Adapter

The DB adapter used by generated components and pages.

Type

\Dewdrop\Db\Adapter

$testCase

$testCase : \Dewdrop\Test\Admin\PHPUnit_Framework_TestCase

The PHPUnit test case this helper was created by.

Type

\Dewdrop\Test\Admin\PHPUnit_Framework_TestCase

$componentFolder

$componentFolder : string

The admin sub-folder the component is located in.

Type

string

$componentNamespace

$componentNamespace : string

The namespace the component classes are assigned to.

Type

string

$mockResponseHelper

$mockResponseHelper : boolean

Whether to mock the execution of response helper actions.

Type

boolean

Methods

__construct()

__construct(\PHPUnit_Framework_TestCase  $testCase, string  $componentFolder, string  $componentNamespace) 

Create new helper object for the supplied test case.

Parameters

\PHPUnit_Framework_TestCase $testCase
string $componentFolder
string $componentNamespace

setMockResponseHelper()

setMockResponseHelper(boolean  $mockResponseHelper) : \Dewdrop\Test\Admin\Helper

Whether to mock the execution of the queued response helper actions.

Parameters

boolean $mockResponseHelper

Returns

\Dewdrop\Test\Admin\Helper

dispatchPage()

dispatchPage(string  $name, array  $post = array(), array  $query = array()) : \Dewdrop\Admin\Response\MockResponse

Dispatch a page, using the supplied page name (e.g. "Index" or "Edit") and request data. If you supply any POST data, the request method will be set to POST as well.

Parameters

string $name
array $post
array $query

Returns

\Dewdrop\Admin\Response\MockResponse

getPage()

getPage(string  $name, array  $post = array(), array  $query = array()) : \Dewdrop\Admin\Page\PageAbstract

Get an object for the named page. Allows you to play with the page outside the stock dispatch loop implemented in ComponentAbstract.

Parameters

string $name
array $post
array $query

Returns

\Dewdrop\Admin\Page\PageAbstract

getResponseHelper()

getResponseHelper(string  $name, array  $post = array(), array  $query = array()) : \Dewdrop\Admin\ResponseHelper\Standard

Complete the init and process portions of the dispatch loop so that we can return the response helper for testing.

Parameters

string $name
array $post
array $query

Returns

\Dewdrop\Admin\ResponseHelper\Standard

getComponent()

getComponent(\Dewdrop\Request  $request) : \Dewdrop\Admin\ComponentAbstract

Get a component object, injecting the supplied request so that we can test different responses.

Parameters

\Dewdrop\Request $request

Returns

\Dewdrop\Admin\ComponentAbstract

createRequest()

createRequest(array  $post = array(), \Dewdrop\Test\Admin\arary  $query = array()) : \Dewdrop\Request

Create a request using the supplied POST and GET values. If there are any POST values, we set the request method to POST.

Parameters

array $post
\Dewdrop\Test\Admin\arary $query

Returns

\Dewdrop\Request