elliotchance / elliotchance/concise

Saved mocks

Open
#75 1 comment 0 reactions 0 assignees View on GitHub
Component: Mocking Size: 3 (Large) Type: Feature
Dominant language
PHP
Stars
45
Forks
3
PR merge metrics
No merged PRs in 30d

Description

A saved mock allows easy and verifiable mocks between integration (or expensive logic) and unit (cheap logic) tests:

``` php
public function test1()
{
$calc = $this->niceMock('Calculator')
->saveAs('calc')
->done();
$this->assert($calc->add(3, 5), equals, 8);
}

public function test2()
{
$calc = $this->savedMock('calc');

// add(3, 5) was prerecorded as returning 8
$this->assert($calc->add(3, 5), equals, 8);

// add(3, 7) was not recorded so it has to go back to the original object to calculate it
$this->assert($calc->add(3, 7), equals, 10);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.