Skip to content

Commit cf6ddd1

Browse files
committed
Fix test to use the new features
1 parent 343545c commit cf6ddd1

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

tests/Integration/NotMatchedRequestTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ private function initialize(string $notMatchedRequestConfig): void
2020
$moduleContainer = $this->createMock(ModuleContainer::class);
2121
$this->sot = new MockServerHelper(
2222
$moduleContainer,
23-
['url' => 'http://mockserver:1080', 'notMatchedRequest' => $notMatchedRequestConfig]
23+
[
24+
'url' => 'http://mockserver:1080',
25+
'notMatchedRequest' => $notMatchedRequestConfig,
26+
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
27+
]
2428
);
2529
$this->sot->_initialize();
30+
$this->sot->_beforeSuite();
2631
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2732
$this->sot->clearMockServerLogs();
2833
}
2934

3035
protected function tearDown(): void
3136
{
37+
$this->sot->removeAllMockRequest();
3238
parent::tearDown();
33-
$this->sot->deactivateNotMatchedRequest();
3439
}
3540

3641
public function testActivateNotMatchedRequestCreateExpectation()

tests/Integration/SeeAllRequestWereMatchedTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ class SeeAllRequestWereMatchedTest extends TestCase
1717
protected function initialize(string $notMatchedRequest): void
1818
{
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
20-
$config = ['url' => 'http://mockserver:1080', 'notMatchedRequest' => $notMatchedRequest];
20+
$config = [
21+
'url' => 'http://mockserver:1080',
22+
'notMatchedRequest' => $notMatchedRequest,
23+
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
24+
];
2125
$this->sot = new MockServerHelper($moduleContainer, $config);
2226
$this->sot->_initialize();
27+
$this->sot->_beforeSuite();
2328
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2429
$this->sot->clearMockServerLogs();
2530
}
2631

32+
protected function tearDown(): void
33+
{
34+
parent::tearDown();
35+
$this->sot->removeAllMockRequest();
36+
}
37+
2738
public function testAllRequestWereMatchedWhenConfigDisabledThrowException(): void
2839
{
2940
$this->initialize(NotMatchedRequest::DISABLED);

tests/Integration/SeeMockRequestWasCalledTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
20-
$this->sot = new MockServerHelper($moduleContainer, ['url' => 'http://mockserver:1080']);
20+
$config = [
21+
'url' => 'http://mockserver:1080',
22+
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
23+
];
24+
$this->sot = new MockServerHelper($moduleContainer, $config);
2125
$this->sot->_initialize();
26+
$this->sot->_beforeSuite();
2227
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2328
$this->sot->clearMockServerLogs();
2429
}
2530

31+
protected function tearDown(): void
32+
{
33+
parent::tearDown();
34+
$this->sot->removeAllMockRequest();
35+
}
36+
2637
public function testExpectationWasCalled(): void
2738
{
2839
$this->client->request('GET', 'https://jsonplaceholder.typicode.com/posts/1');

tests/Integration/SeeMockRequestWasNotCalledTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,24 @@ class SeeMockRequestWasNotCalledTest extends TestCase
1616
protected function setUp(): void
1717
{
1818
parent::setUp();
19+
$config = [
20+
'url' => 'http://mockserver:1080',
21+
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
22+
];
1923
$moduleContainer = $this->createMock(ModuleContainer::class);
20-
$this->sot = new MockServerHelper($moduleContainer, ['url' => 'http://mockserver:1080']);
24+
$this->sot = new MockServerHelper($moduleContainer, $config);
2125
$this->sot->_initialize();
26+
$this->sot->_beforeSuite();
2227
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2328
$this->sot->clearMockServerLogs();
2429
}
2530

31+
protected function tearDown(): void
32+
{
33+
parent::tearDown();
34+
$this->sot->removeAllMockRequest();
35+
}
36+
2637
public function testExpectationWasNotCalled(): void
2738
{
2839
$this->sot->seeMockRequestWasNotCalled('get-post-2');

0 commit comments

Comments
 (0)