Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Api/Operator/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getAll(?string $field, $value): array
$response = $this->getBy('get-db', $field, $value);
$items = [];
foreach ((array) $response->xpath('//result') as $xmlResult) {
if ($xmlResult) {
if (isset($xmlResult->id) && (int) $xmlResult->id > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$xmlResult check was removed w/o a reason. Please also make sure composer lint doesn't emit any errors.

$items[] = new Struct\Info($xmlResult);
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,15 @@ private function createUser(array $params): \PleskX\Api\Struct\Database\UserInfo

return $user;
}

public function testGetAllForWebspaceWithNoDatabases()
{
$webspace = static::createWebspace();
$databases = static::$client->database()->getAll('webspace-id', $webspace->id);

$this->assertIsArray($databases);
$this->assertEmpty($databases);

static::$client->webspace()->delete('id', $webspace->id);
}
}
Loading