PHP Class VersionPress\Tests\Utils\HookMock

It does two types of "mocking": a) The first type simulates behavior of WordPress (TRUE_HOOKS). With this type you can call add_filter and apply_filters and the registered filter will be actually executed. b) The second type uses WP_MOCK. You can use all features of WP_MOCK if you choose it. The problem is, WP_MOCK does not execute the registered hooks; therefore, we introduced this thin wrapper. Usage: Just call HookMock::setUp with desired type of mocking in the setUp method of your test case and HookMock::tearDown in the tearDown method. Note: For now, this class supports only filters.
Show file Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
addAction ( $tag, $fn, $priority = 10, $acceptedArgs = 1 )
addFilter ( $tag, $fn, $priority = 10, $acceptedArgs = 1 )
applyFilters ( $tag, $value )
doAction ( $tag, $arg = '' )
setUp ( $type = HookMock::TRUE_HOOKS )
tearDown ( )

Private Methods

Method Description
getRelatedHooks ( $tag, $hookType )

Method Details

addAction() public static method

public static addAction ( $tag, $fn, $priority = 10, $acceptedArgs = 1 )

addFilter() public static method

public static addFilter ( $tag, $fn, $priority = 10, $acceptedArgs = 1 )

applyFilters() public static method

public static applyFilters ( $tag, $value )

doAction() public static method

public static doAction ( $tag, $arg = '' )

setUp() public static method

public static setUp ( $type = HookMock::TRUE_HOOKS )

tearDown() public static method

public static tearDown ( )