You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -12,17 +12,15 @@ Tired of spending most of your testing time mocking objects like there's no tomo
12
12
13
13
## Installation
14
14
15
-
You can simply install the package via composer:
15
+
You can install the package via composer:
16
16
17
17
```bash
18
18
composer require --dev facile-it/moka
19
19
```
20
20
21
21
## Usage
22
22
23
-
To use **Moka** in your tests simply `use` function `Moka\Plugin\PHPUnit\moka()` (see generators section [below](#strategies)) and run `Moka::clean()` before every test. A simple interface will let you create *moka* (mock) objects and decorate them with *stub* methods with a fluent interface.
24
-
25
-
A complete example follows:
23
+
To use **Moka** in your tests simply `use` function `Moka\Plugin\PHPUnit\moka()` (see generators section [below](#strategies)) and run `Moka::clean()` before every test. A simple interface will let you create *moka* (mock) objects and decorate them with *stub* methods via a fluent interface:
Accepts an array of method stubs with format `[$methodName => $methodValue]`, where `$methodName`**must** be a string and `$methodValue` can be of any type, including another mock object or an exception instance:
132
+
Accepts an array of method stubs with format `[$methodName => $methodValue]`, where `$methodName`**must** be a string and `$methodValue` can be of any type, including another mock object or an exception instance (which will be thrown):
135
133
136
134
```php
137
135
$mock = moka(BarInterface::class)->stub([
@@ -144,7 +142,7 @@ var_dump($mock->isValid());
144
142
// bool(true)
145
143
```
146
144
147
-
**Notice:** the stub is valid for **any** invocation of the method and it cannot be overridden.
145
+
**Notice:** the stub is valid for **any** invocation of the method and cannot be overridden.
148
146
If you need more granular control over invocation strategies, you can get [access to the original mock object implementation](#original-mock).
0 commit comments