Skip to content

Commit 07ed9ec

Browse files
committed
more documentation
1 parent dbd6e8b commit 07ed9ec

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

README.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
This package integrates the function mock library
44
[PHP-Mock](https://github.com/php-mock/php-mock) with PHPUnit.
55

6-
# Requirements
7-
86
# Installation
97

8+
Use [Composer](https://getcomposer.org/):
9+
10+
```json
11+
{
12+
"require-dev": {
13+
"php-mock/phpunit": "0.1"
14+
}
15+
}
16+
```
17+
1018
# Usage
1119

1220
PHP-Mock integrates with the trait
@@ -24,20 +32,40 @@ namespace foo;
2432

2533
use phpmock\phpunit\PHPMock;
2634

27-
class FooTest extends \PHPUnit_Framework_TestCase
35+
class BuiltinTest extends \PHPUnit_Framework_TestCase
2836
{
2937

3038
use PHPMock;
3139

32-
public function testBar()
40+
public function testTime()
3341
{
3442
$time = $this->getFunctionMock(__NAMESPACE__, "time");
3543
$time->expects($this->once())->willReturn(3);
44+
3645
$this->assertEquals(3, time());
3746
}
47+
48+
public function testExec()
49+
{
50+
$exec = $this->getFunctionMock(__NAMESPACE__, "exec");
51+
$exec->expects($this->once())->willReturnCallback(
52+
function ($command, &$output, &$return_var) {
53+
$this->assertEquals("foo", $command);
54+
$output = ["failure"];
55+
$return_var = 1;
56+
}
57+
);
58+
59+
exec("foo", $output, $return_var);
60+
$this->assertEquals(["failure"], $output);
61+
$this->assertEquals(1, $return_var);
62+
}
3863
}
3964
```
4065

66+
There's no need to disable the mocked function. The PHPUnit integration does
67+
that for you.
68+
4169
# License and authors
4270

4371
This project is free and under the WTFPL.

0 commit comments

Comments
 (0)