diff --git a/API.md b/API.md index e39dc9e..3fbbd10 100644 --- a/API.md +++ b/API.md @@ -78,7 +78,7 @@ expect_spy( $spy )->to_have_been_called->with( any() ); finish_spying(); ``` -- `match_array()`: Used as an argument to `Expectation->with()` to mean "any argument with these values". Shortcut for `new MatchArray()`. +- `match_array()`: Used as an argument to `Expectation->with()` or `Spy()->with()` to mean "any argument with these values". Shortcut for `new MatchArray()`. ```php $spy = get_spy_for( 'wp_update_post' ); @@ -87,6 +87,12 @@ expect_spy( $spy )->to_have_been_called->with( match_array( [ 'status' => 'publi finish_spying(); ``` +```php +mock_function( 'wp_update_post' )->when_called->with( match_array( [ 'title' => 'hello' ] ) )->will_return( 14 ); +$id = wp_update_post( [ 'title' => 'hello', 'status' => 'publish', 'post_content' => 'slartibartfast' ] ); +$this->assertEquals( 14, $id ); +``` + - `passed_arg( $index )`: Used as an argument to `Spy->and_return()` to mean "return the passed argument at $index". Shortcut for `new PassedArgument( $index )`. ```php