Skip to content

Commit

Permalink
Fix doc example to install WP_Mock via composer (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
unfulvio-godaddy authored Jun 16, 2023
1 parent 8961bda commit 9ce8001
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WP_Mock

> WP_Mock is an API mocking framework, built and maintained by [10up](http://10up.com) and [GoDaddy](https://godaddy.com) for the purpose of making it possible to properly unit test within a WordPress project.
> WP_Mock is an API mocking framework, built and maintained by [10up](https://10up.com) and [GoDaddy](https://godaddy.com) for the purpose of making it possible to properly unit test within a WordPress project.
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) ![PHP 7.3+][php-image] [![Coverage Status][coveralls-image]][coveralls-url] [![Packagist][packagist-image]][packagist-url] [![GPLv2 License](https://img.shields.io/badge/license-GPL--2.0-orange)](https://github.com/10up/wp_mock/blob/trunk/LICENSE.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/general/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The bootstrap file can do a few things:

## Configure PHPUnit with WP_Mock

You can run PHPUnit using a `--bootstrap` flag to include your boostrap configuration while executing your tests (see [PHPUnit documentation](https://docs.phpunit.de/en/9.5/textui.html?highlight=--bootstrap#command-line-options):
You can run PHPUnit using a `--bootstrap` flag to include your boostrap configuration while executing your tests (see [PHPUnit documentation](https://docs.phpunit.de/en/9.5/textui.html?highlight=--bootstrap#command-line-options)):

```shell
./vendor/bin/phpunit --bootstrap /path/to/bootstrap.php
Expand Down
2 changes: 1 addition & 1 deletion docs/general/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Add WP_Mock as a dev-dependency using Composer:

```shell
composer require --dev 10up/wp:mock
composer require --dev 10up/wp_mock
```

## Dependencies
Expand Down
4 changes: 2 additions & 2 deletions docs/general/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## What is WP_Mock

[WP_Mock](https://github.com/10up/wp_mock) is a unit test tool for PHP projects that extend or build upon , such as plugins, themes, or even whole websites.
[WP_Mock](https://github.com/10up/wp_mock) is a unit test tool for PHP projects that extend or build upon [WordPress](https://wordpress.org/), such as plugins, themes, or even whole websites.

WP_Mock helps mocking common WordPress functions and components, making it easier to write unit tests for your project. It also helps perform additional assertions over your code that are not part of the standard toolset.
WP_Mock helps mock common WordPress functions and components, making it easier to write unit tests for your project. It also helps perform additional assertions over your code that are not part of the standard toolset.

When writing code for WordPress, it so often happens that the code you create needs to invoke a WordPress function, class or hook, which is external code you are integrating your project with. Ideally, though, a unit test will not depend on WordPress being loaded in order to test your code. By constructing mocks, it's possible to simulate WordPress core functionality by defining their expected arguments, responses, the number of times they are called, and more.
2 changes: 1 addition & 1 deletion docs/usage/using-wp-mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ return WP_Mock\Handler::handle_function(__FUNCTION__, func_get_args());

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`.

For example, the invocation below will set the expectation that the `get_permalink` function will be called exactly once, with the argument `42`, and that it will return the string `'https://example.com/foo'`.
For example, the invocation below will set the expectation that the `get_permalink()` function will be called exactly once, with the argument `42`, and that it will return the string `'https://example.com/foo'`.

```php
WP_Mock::userFunction('get_permalink')->once()->with(42)->andReturn('https://example.com/foo');
Expand Down

0 comments on commit 9ce8001

Please sign in to comment.