Skip to content

Commit

Permalink
Added GitBook hint style and link to full WP_MockTestCase documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohryan committed Jan 10, 2024
1 parent b242561 commit 1b0aa27
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/usage/using-wp-mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,17 @@ Calling `WP_Mock::userFunction()` will dynamically define the function for you i
return \WP_Mock\Functions\Handler::handleFunction(__FUNCTION__, func_get_args());
```


{% hint style="warning" %}

**Important!**

Note how in the above test class `WP_Mock\Tools\TestCase` was extended instead of `PHPUnit\Framework\TestCase`. This is because WP_Mock provides a custom test case class that extends PHPUnit's test case class and adds additional functionality to it. Ideally, you should always extend `WP_Mock\Tools\TestCase` instead of `PHPUnit\Framework\TestCase` when using WP_Mock. _If you do not wish to extend WP_Mock own test case class_ you should make sure to call `WP_Mock::setUp()` and `WP_Mock::tearDown()` in your test case's `setUp()` and `tearDown()` methods respectively.

See [WP_Mock Test Case Documentation](../tools/wp-mock-test-case.md)

{% endhint %}

## Using Mockery expectations

The `WP_Mock::userFunction()` class will return a complete `Mockery\Expectation` object with any expectations added to match the arguments passed to the function. This enables using [Mockery methods](http://docs.mockery.io/en/latest/reference/expectations.html) to add expectations in addition to, or instead of using the arguments array passed to `userFunction`.
Expand Down

0 comments on commit 1b0aa27

Please sign in to comment.