Skip to content

Commit

Permalink
Merge pull request #66 from solusio/bugfix-mkorsakov-update-fqdn-on-h…
Browse files Browse the repository at this point in the history
…ostname-change-SIO-3769

BUGFIX SIO-3769 update fqdns on hostname change
  • Loading branch information
acidmk authored Oct 25, 2021
2 parents 51b16a4 + 31e03d7 commit 4adf5b4
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 4adf5b4

Please sign in to comment.