Skip to content

Commit 535df0c

Browse files
committed
Add url as mandatory parameter in the configuration
1 parent 6cd803d commit 535df0c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/MockServerHelper.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DEVizzent\CodeceptionMockServerHelper;
44

5+
use Codeception\Lib\ModuleContainer;
56
use Codeception\Module;
67
use Codeception\TestInterface;
78
use GuzzleHttp\Client;
@@ -10,21 +11,20 @@
1011

1112
class MockServerHelper extends Module
1213
{
13-
14-
/**
15-
* @var array<string, string> $config
16-
*/
17-
protected array $config = [
18-
'url' => 'http://mockserver:1080',
19-
'cleanupBefore' => 'test'
20-
];
21-
2214
private Client $mockserverClient;
15+
public function __construct(ModuleContainer $moduleContainer, ?array $config = null)
16+
{
17+
$this->requiredFields = ['url'];
18+
$this->config['cleanupBefore'] = 'test';
19+
parent::__construct($moduleContainer, $config);
20+
}
2321

2422

2523
public function _initialize(): void
2624
{
27-
$this->mockserverClient = new Client(['base_uri' => $this->config['url']]);
25+
$this->mockserverClient = new Client([
26+
'base_uri' => $this->config['url']
27+
]);
2828
}
2929

3030
public function _beforeSuite(array $settings = []): void

tests/Integration/SeeMockRequestWasCalledTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
20-
$this->sot = new MockServerHelper($moduleContainer);
20+
$this->sot = new MockServerHelper($moduleContainer, ['url' => 'http://mockserver:1080']);
2121
$this->sot->_initialize();
2222
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2323
$this->sot->clearMockServerLogs();

tests/Integration/SeeMockRequestWasNotCalledTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
20-
$this->sot = new MockServerHelper($moduleContainer);
20+
$this->sot = new MockServerHelper($moduleContainer, ['url' => 'http://mockserver:1080']);
2121
$this->sot->_initialize();
2222
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
2323
$this->sot->clearMockServerLogs();

0 commit comments

Comments
 (0)