Skip to content

Commit

Permalink
fix: Add port as methods argument for stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
demyan112rv committed Jul 18, 2024
1 parent 817a6b2 commit 56fa7b3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Mountebank.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public function getImpostersUrl(): string
return $this->host . ':' . $this->port . '/' . static::URI_IMPOSTERS;
}

public function getStubsUrl(): string
public function getStubsUrl(int $port): string
{
return $this->getImpostersUrl() . '/' . $this->port . '/' . static::URI_STUBS;
return $this->getImpostersUrl() . '/' . $port . '/' . static::URI_STUBS;
}

public function getLogsUrl(): string
Expand Down Expand Up @@ -134,10 +134,10 @@ public function removeImposters(): ResponseInterface
/**
* @codeCoverageIgnore
*/
public function addStub(Stub $stub, int $index): ResponseInterface
public function addStub(Stub $stub, int $port, int $index): ResponseInterface
{
$formattedStub = (new Formatter())->stubToArray($stub);
return $this->client->request('POST', $this->getStubsUrl(), [
return $this->client->request('POST', $this->getStubsUrl($port), [
RequestOptions::BODY => \json_encode([
'index' => $index,
'stub' => $formattedStub,
Expand All @@ -152,10 +152,10 @@ public function addStub(Stub $stub, int $index): ResponseInterface
/**
* @codeCoverageIgnore
*/
public function updateStub(Stub $stub, int $index): ResponseInterface
public function updateStub(Stub $stub, int $port, int $index): ResponseInterface
{
$formattedStub = (new Formatter())->stubToArray($stub);
return $this->client->request('PUT', $this->getStubsUrl() . '/' . $index, [
return $this->client->request('PUT', $this->getStubsUrl($port) . '/' . $index, [
RequestOptions::BODY => \json_encode($formattedStub),
RequestOptions::HEADERS => [
'Content-Type' => 'application/json',
Expand All @@ -167,9 +167,9 @@ public function updateStub(Stub $stub, int $index): ResponseInterface
/**
* @codeCoverageIgnore
*/
public function deleteStub(int $index): ResponseInterface
public function deleteStub(int $port, int $index): ResponseInterface
{
return $this->client->request('DELETE', $this->getStubsUrl() . '/' . $index, [
return $this->client->request('DELETE', $this->getStubsUrl($port) . '/' . $index, [
RequestOptions::HEADERS => [
'Content-Type' => 'application/json',
'Accept' => 'application/json'
Expand Down

0 comments on commit 56fa7b3

Please sign in to comment.