PHP Class Phergie_Plugin_TestCase, phergie

Author: Phergie Development Team ([email protected])
Inheritance: extends PHPUnit_Framework_TestCase
Show file Open project: phergie/phergie Class Usage Examples

Protected Properties

Property Type Description
$plugin Phergie_Plugin_Abstract Plugin instance being tested
$pluginClass string Full name of the plugin class being tested, may be explicitly specified in subclasses but is otherwise automatically derived from the test case class name

Public Methods

Method Description
assertRemovesPlugin ( string | Phergie_Plugin_Abstract | array $plugin ) : void Modifies the plugin handler to include an expectation of a plugin being removed. Note that this must be called BEFORE executing the plugin code that may remove that plugin.
assertRequiresPlugin ( string | array $name ) : void Modifies the plugin handler to include an expectation of a plugin being retrieved, indicating a dependency. Note that this must be called BEFORE executing the plugin code that may load that plugin dependency, which is usually located in onLoad().
getMockDatabase ( string $path ) : PDO Creates an in-memory copy of a specified SQLite database file and returns a connection to it.
removePlugin ( string | Phergie_Plugin_Abstract $plugin ) : void Records an actual plugin removal.
requirePlugin ( string $name ) : Phergie_Plugin_Abstract Records an actual plugin requirement.
setUp ( ) : void Initializes instance properties.
tearDown ( ) : void Destroys all initialized instance properties.

Protected Methods

Method Description
assertDoesNotEmitEvent ( string $type, array $args = [] ) : void Modifies the event handler to include an expectation of an event NOT being added by the plugin being tested. Note that this must be called BEFORE executing plugin code that may initiate the event.
assertEmitsEvent ( string $type, array $args = [] ) : void Modifies the event handler to include an expectation of an event being added by the plugin being tested. Note that this must be called BEFORE executing the plugin code intended to initiate the event.
getPluginsPath ( string $subpath = null ) : string Returns the absolute path to the Phergie/Plugin directory. Useful in conjunction with getMockDatabase().

Method Details

assertDoesNotEmitEvent() protected method

Modifies the event handler to include an expectation of an event NOT being added by the plugin being tested. Note that this must be called BEFORE executing plugin code that may initiate the event.
protected assertDoesNotEmitEvent ( string $type, array $args = [] ) : void
$type string Event type
$args array Optional enumerated array of event arguments
return void

assertEmitsEvent() protected method

Modifies the event handler to include an expectation of an event being added by the plugin being tested. Note that this must be called BEFORE executing the plugin code intended to initiate the event.
protected assertEmitsEvent ( string $type, array $args = [] ) : void
$type string Event type
$args array Optional enumerated array of event arguments
return void

assertRemovesPlugin() public method

Modifies the plugin handler to include an expectation of a plugin being removed. Note that this must be called BEFORE executing the plugin code that may remove that plugin.
public assertRemovesPlugin ( string | Phergie_Plugin_Abstract | array $plugin ) : void
$plugin string | Phergie_Plugin_Abstract | array Short name of the plugin or the plugin instance to be removed or an array of multiple instances of either
return void

assertRequiresPlugin() public method

Modifies the plugin handler to include an expectation of a plugin being retrieved, indicating a dependency. Note that this must be called BEFORE executing the plugin code that may load that plugin dependency, which is usually located in onLoad().
public assertRequiresPlugin ( string | array $name ) : void
$name string | array Short name of the plugin required as a dependency or an array containing multiple instances thereof
return void

getMockDatabase() public method

Creates an in-memory copy of a specified SQLite database file and returns a connection to it.
public getMockDatabase ( string $path ) : PDO
$path string Path to the SQLite file to copy
return PDO Connection to the database copy

getPluginsPath() protected method

Returns the absolute path to the Phergie/Plugin directory. Useful in conjunction with getMockDatabase().
protected getPluginsPath ( string $subpath = null ) : string
$subpath string Optional path to append to the directory path
return string Directory path

removePlugin() public method

Records an actual plugin removal.
public removePlugin ( string | Phergie_Plugin_Abstract $plugin ) : void
$plugin string | Phergie_Plugin_Abstract Short name of the plugin or the plugin instance to be removed
return void

requirePlugin() public method

Records an actual plugin requirement.
public requirePlugin ( string $name ) : Phergie_Plugin_Abstract
$name string Short name of the plugin required as a dependency
return Phergie_Plugin_Abstract Mock instance of the specified plugin

setUp() public method

Initializes instance properties.
public setUp ( ) : void
return void

tearDown() public method

Destroys all initialized instance properties.
public tearDown ( ) : void
return void

Property Details

$plugin protected property

Plugin instance being tested
protected Phergie_Plugin_Abstract $plugin
return Phergie_Plugin_Abstract

$pluginClass protected property

Full name of the plugin class being tested, may be explicitly specified in subclasses but is otherwise automatically derived from the test case class name
protected string $pluginClass
return string