Spork Code Libraries

TestCaseView

PHPUnit test case for testing view templates

NOTE: This was written for MySQL and probably won't work with other databases.

Database is initialized on first use by coping the structure of existing tables and creating temporary tables on top of them. The temporary tables are then truncated and reused on additional tests to speed up performance. Temporary tables are changed to use the Memory engine when possible to speed up performance.

Extends

Properties

$dbInitialized

$dbInitialized : boolean

Has database been initialized

Type

boolean
Inherited from
\Spork\Test\TestCase\TestCaseDb

$dbAdapter

$dbAdapter : \Zend\Db\Adapter\AdapterInterface

Database adapter

Type

\Zend\Db\Adapter\AdapterInterface
Inherited from
\Spork\Test\TestCase\TestCaseDb

$config

$config : 

Type

Inherited from
\Spork\Test\TestCase\TestCaseService

$configPath

$configPath : 

Type

Inherited from
\Spork\Test\TestCase\TestCaseService

$cloneServices

$cloneServices : boolean

Should services be cloned from prototype or created from scratch. This is experimental and should be used with caution.

Type

boolean
Inherited from
\Spork\Test\TestCase\TestCaseService

$serviceManagerPrototype

$serviceManagerPrototype : \Zend\ServiceManager\ServiceManager

Service Manager Prototype

Type

\Zend\ServiceManager\ServiceManager
Inherited from
\Spork\Test\TestCase\TestCaseService

$services

$services : \Zend\ServiceManager\ServiceLocatorInterface

Service Manager

Type

\Zend\ServiceManager\ServiceLocatorInterface
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

$model

$model : \Zend\View\Model\ModelInterface

View Model

Type

\Zend\View\Model\ModelInterface

$response

$response : string

Output of rendered template

Type

string

Methods

__destruct()

__destruct() 

Unset services

Inherited from
\Spork\ServiceManager\ServicesAwareTrait

getServices()

getServices() : \Zend\ServiceManager\ServiceLocatorInterface

Get Service Manager

Returns

\Zend\ServiceManager\ServiceLocatorInterface
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

setServices()

setServices(\Zend\ServiceManager\ServiceLocatorInterface  $services) 

Set Service Manager

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $services
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

getServiceLocator()

getServiceLocator() : \Zend\ServiceManager\ServiceLocatorInterface

Provides compatibility ServiceLocatorAwareInterface

Returns

\Zend\ServiceManager\ServiceLocatorInterface
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

setServiceLocator()

setServiceLocator(\Zend\ServiceManager\ServiceLocatorInterface  $services) 

Provides compatibility ServiceLocatorAwareInterface

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $services
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

getServiceManager()

getServiceManager() : \Zend\ServiceManager\ServiceLocatorInterface

Provides compatibility ServiceManagerAwareInterface

Returns

\Zend\ServiceManager\ServiceLocatorInterface
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

setServiceManager()

setServiceManager(\Zend\ServiceManager\ServiceLocatorInterface  $services) 

Provides compatibility ServiceManagerAwareInterface

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $services
Inherited from
\Spork\ServiceManager\ServicesAwareTrait

assertTableRowCount()

assertTableRowCount(integer  $count, string|\Zend\Db\TableGateway  $table, string|array|\Spork\Test\TestCase\Closure|\Spork\Test\TestCase\PredicateInterface  $where = null) 

Assert that a table has specified number for rows

Parameters

integer $count
string|\Zend\Db\TableGateway $table
string|array|\Spork\Test\TestCase\Closure|\Spork\Test\TestCase\PredicateInterface $where

Throws

\Exception

on $table not a table name or TableGateway instance

Inherited from
\Spork\Test\TestCase\TestCaseDb

setUp()

setUp() 

Initialize View Model instance

See also

tearDown()

tearDown() 

Remove View Model

See also

initializePrototype()

initializePrototype() 

Create a Service Manager Prototype object

Inherited from
\Spork\Test\TestCase\TestCaseService

render()

render(string  $template = null) 

Render a template

Parameters

string $template

addVariable()

addVariable(string  $name, mixed  $value) 

Add a variable to the View Model

Parameters

string $name
mixed $value

setVariables()

setVariables(array  $variables) 

Set a list of variables in the View Model

Parameters

array $variables

addChild()

addChild(\Zend\View\Model\ViewModel  $child, string  $captureTo = null, string  $append = false) 

Add a child View Model to top View Model

Parameters

\Zend\View\Model\ViewModel $child
string $captureTo
string $append

getApplication()

getApplication() : \Zend\Mvc\Application

Get application

Returns

\Zend\Mvc\Application

getViewManager()

getViewManager() : \Zend\Mvc\View\Http\ViewManager

Get view manager

Returns

\Zend\Mvc\View\Http\ViewManager

initializeDatabase()

initializeDatabase(\Zend\Db\Adapter\Adapter  $source, \Zend\Db\Adapter\Adapter  $dest) 

Parameters

\Zend\Db\Adapter\Adapter $source
\Zend\Db\Adapter\Adapter $dest
Inherited from
\Spork\Test\TestCase\TestCaseDb

createTestTable()

createTestTable(string  $table, \Zend\Db\Adapter\Adapter  $source, \Zend\Db\Adapter\Adapter  $dest) 

Copies table structure and creates temporary table on top of it.

Parameters

string $table

Table name

\Zend\Db\Adapter\Adapter $source
\Zend\Db\Adapter\Adapter $dest
Inherited from
\Spork\Test\TestCase\TestCaseDb

getCreateTable()

getCreateTable(string  $table, \Zend\Db\Adapter\Adapter  $db) : mixed

Gets table structure

Parameters

string $table

Table name

\Zend\Db\Adapter\Adapter $db

Returns

mixed
Inherited from
\Spork\Test\TestCase\TestCaseDb

getTables()

getTables(\Zend\Db\Adapter\Adapter  $db) : array

Get list of tables in current schema

Parameters

\Zend\Db\Adapter\Adapter $db

Returns

array
Inherited from
\Spork\Test\TestCase\TestCaseDb