Skip to content

Commit c41e851

Browse files
author
Mariano Custiel
committed
-: Post-merge fixes
1 parent d0de6a6 commit c41e851

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ modules:
7171
- Phiremock:
7272
host: 127.0.0.1
7373
port: 18080
74+
resetBeforeEachTest: false # if set to true, executes `$I->haveACleanSetupInRemoteService` before each test.
7475
```
7576
7677
#### Use
@@ -90,7 +91,7 @@ Allows you to setup an expectation in Phiremock, specifying the expected request
9091
```
9192

9293
#### haveACleanSetupInRemoteService
93-
Cleans the server of all configured expectations, scenarios and requests history.
94+
Cleans the server of all configured expectations, scenarios and requests history, and reloads expectation files.
9495

9596
```php
9697
$I->haveACleanSetupInRemoteService();
@@ -124,7 +125,6 @@ Resets the requests counter for the verifier in Phiremock.
124125
$I->didNotReceiveRequestsInRemoteService();
125126
```
126127

127-
128128
## Use case
129129

130130
### Yii2-Curl

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"require" : {
3030
"php" : ">=5.6",
3131
"mcustiel/phiremock": "^1.3",
32-
"codeception/codeception" : "^2.0",
32+
"codeception/codeception" : "^2.2",
3333
"symfony/process": "^3.3"
3434
}
3535
}

src/Extension/Phiremock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ private function executeDelay()
101101
*/
102102
private function initProcess($process)
103103
{
104-
$this->process = $process === null ? new PhiremockProcess() : $process;
104+
$this->process = null === $process ? new PhiremockProcess() : $process;
105105
}
106106
}

src/Extension/PhiremockProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function initProcess($ip, $port, $debug, $expectationsPath, $phiremockPa
8282
'-i',
8383
$ip,
8484
'-p',
85-
$port
85+
$port,
8686
];
8787
if ($debug) {
8888
$commandline[] = '-d';

src/Module/Phiremock.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace Codeception\Module;
2020

2121
use Codeception\Module as CodeceptionModule;
22+
use Codeception\TestInterface;
2223
use Mcustiel\Phiremock\Client\Phiremock as PhiremockClient;
2324
use Mcustiel\Phiremock\Client\Utils\RequestBuilder;
2425
use Mcustiel\Phiremock\Domain\Expectation;
@@ -29,9 +30,9 @@ class Phiremock extends CodeceptionModule
2930
* @var array
3031
*/
3132
protected $config = [
32-
'host' => 'localhost',
33-
'port' => '8086',
34-
'cleanup' => false,
33+
'host' => 'localhost',
34+
'port' => '8086',
35+
'resetBeforeEachTest' => false,
3536
];
3637

3738
/**
@@ -47,8 +48,8 @@ public function _beforeSuite($settings = [])
4748

4849
public function _before(TestInterface $test)
4950
{
50-
if ($this->config['cleanup']) {
51-
$this->haveInitialSetupRestored();
51+
if ($this->config['resetBeforeEachTest']) {
52+
$this->haveACleanSetupInRemoteService();
5253
}
5354
parent::_before($test);
5455
}
@@ -60,14 +61,7 @@ public function expectARequestToRemoteServiceWithAResponse(Expectation $expectat
6061

6162
public function haveACleanSetupInRemoteService()
6263
{
63-
$this->phiremock->clearExpectations();
64-
$this->phiremock->resetRequestsCounter();
65-
$this->phiremock->resetScenarios();
66-
}
67-
68-
public function haveInitialSetupRestored()
69-
{
70-
$this->phiremock->restoreExpectations();
64+
$this->phiremock->reset();
7165
}
7266

7367
public function dontExpectRequestsInRemoteService()
@@ -86,6 +80,12 @@ public function didNotReceiveRequestsInRemoteService()
8680
$this->phiremock->resetRequestsCounter();
8781
}
8882

83+
/**
84+
* @param int $times
85+
* @param RequestBuilder $builder
86+
*
87+
* @throws \Exception
88+
*/
8989
public function seeRemoteServiceReceived($times, RequestBuilder $builder)
9090
{
9191
$requests = $this->phiremock->countExecutions($builder);

0 commit comments

Comments
 (0)