Skip to content

Commit 650c1ef

Browse files
committed
prevented incorrect handling of empty secret key list
1 parent f45ef4d commit 650c1ef

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/PleskX/Api/Operator/SecretKey.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public function _get($keyId = null)
6565
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
6666

6767
$items = [];
68-
foreach ($response->xpath('//result') as $xmlResult) {
69-
$items[] = new Struct\Info($xmlResult->key_info);
68+
foreach ($response->xpath('//result/key_info') as $keyInfo) {
69+
$items[] = new Struct\Info($keyInfo);
7070
}
7171

7272
return $items;

tests/SecretKeyTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ public function testDelete()
5151
}
5252
}
5353

54+
public function testListEmpty()
55+
{
56+
$keys = $this->_client->secretKey()->getAll();
57+
foreach ($keys as $key) {
58+
$this->_client->secretKey()->delete($key->key);
59+
}
60+
61+
$keys = $this->_client->secretKey()->getAll();
62+
$this->assertEquals(0, count($keys));
63+
}
5464
}

0 commit comments

Comments
 (0)