Created
March 27, 2013 17:23
-
-
Save ericmann/5256251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyTestClass extends PHPUnit_Framework_TestCase { | |
public function setUp() { | |
\WP_Mock::setUp(); | |
} | |
public function tearDown() { | |
\WP_Mock::tearDown(); | |
} | |
public function test_content_filter() { | |
\WP_Mock::onFilter( 'the_content' )->with( 'Windows Rocks!' )->reply( 'Apple Rocks!' ); | |
$content = 'Windows Rocks!'; | |
$filtered = apply_filters( 'the_content', $content ); | |
$this->assertEquals( 'Apple Rocks!', $filtered ); | |
} | |
/** | |
* Our special_action function must actually invoke the 'special_action' action when it's done. | |
* function special_action() { | |
* // ... do stuff | |
* do_action( 'special_action' ); | |
* } | |
*/ | |
public function test_method_has_action() { | |
$hook_intercept = \Mockery::mock( 'intercept' ); | |
$hook_intercept->shouldReceive( 'intercepted' ); | |
\WP_Mock::onAction( 'special_action' )->with( null )->perform( array( $hook_intercept, 'intercepted' ) ); | |
// If this function does not call `do_action( 'special_action' )`, the test will fail. | |
special_action(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment