Skip to content

Commit

Permalink
BUGFIX SIO-3769 update fqdns on hostname change
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Korsakov committed Oct 25, 2021
1 parent 51b16a4 commit 31e03d7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function __construct(ClientInterface $connector)
$this->connector = $connector;
}

public function getConnector(): ClientInterface
{
return $this->connector;
}

/**
* @param $response
* @return array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ public function resetPassword(int $id): array

public function changeHostname(int $id, string $hostname): array
{
return $this->processResponse($this->connector->patch("servers/{$id}", [
return $this->processResponse($this->getConnector()->patch("servers/{$id}", [
'json' => [
'name' => $hostname,
'fqdns' => [ $hostname ],
],
]));
}
Expand Down
41 changes: 41 additions & 0 deletions tests/lib/SolusAPI/Resources/ServerResourceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// Copyright 2021. Plesk International GmbH.

namespace Tests\lib\SolusAPI\Resources;

use Mockery;
use PHPUnit\Framework\TestCase;
use WHMCS\Module\Server\SolusIoVps\SolusAPI\Resources\ServerResource;

/**
* @runTestsInSeparateProcesses
*/
class ServerResourceTest extends TestCase
{
public function testChangeHostname(): void
{
$id = 1;
$hostname = 'test.domain.tld';

$serverResource = Mockery::mock(ServerResource::class)
->shouldAllowMockingProtectedMethods()
->makePartial();

$serverResource->shouldReceive('processResponse')->andReturn([]);
$serverResource->shouldReceive('getConnector->patch')->with(
"servers/{$id}",
[
'json' => [
'name' => $hostname,
'fqdns' => [ $hostname ],
],
],
);

$this->addToAssertionCount(
Mockery::getContainer()->mockery_getExpectationCount()
);

$serverResource->changeHostname($id, $hostname);
}
}

0 comments on commit 31e03d7

Please sign in to comment.