Skip to content

Commit a665af5

Browse files
committed
Prefill object id for fetch operations
1 parent 9fb853c commit a665af5

10 files changed

+25
-1
lines changed

src/Api/Operator.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ protected function _getItems($structClass, $infoTag, $field = null, $value = nul
9696
if (!isset($xmlResult->data) || !isset($xmlResult->data->$infoTag)) {
9797
continue;
9898
}
99-
$items[] = new $structClass($xmlResult->data->$infoTag);
99+
$item = new $structClass($xmlResult->data->$infoTag);
100+
if (isset($xmlResult->id) && property_exists($item, 'id')) {
101+
$item->id = (int) $xmlResult->id;
102+
}
103+
$items[] = $item;
100104
}
101105

102106
return $items;

src/Api/Struct/Customer/GeneralInfo.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
class GeneralInfo extends \PleskX\Api\Struct
77
{
8+
/** @var int */
9+
public $id;
10+
811
/** @var string */
912
public $company;
1013

src/Api/Struct/Site/GeneralInfo.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
class GeneralInfo extends \PleskX\Api\Struct
77
{
8+
/** @var int */
9+
public $id;
10+
811
/** @var string */
912
public $creationDate;
1013

src/Api/Struct/Webspace/GeneralInfo.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
class GeneralInfo extends \PleskX\Api\Struct
77
{
8+
/** @var int */
9+
public $id;
10+
811
/** @var string */
912
public $creationDate;
1013

tests/CustomerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function testGet()
4949
$this->assertEquals('[email protected]', $customerInfo->email);
5050
$this->assertEquals('Good guy', $customerInfo->description);
5151
$this->assertEquals('link:12345', $customerInfo->externalId);
52+
$this->assertEquals($customer->id, $customerInfo->id);
5253

5354
static::$_client->customer()->delete('id', $customer->id);
5455
}

tests/MailTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function testGet()
6161

6262
$mailnameInfo = static::$_client->mail()->get('test', static::$webspace->id);
6363
$this->assertEquals('test', $mailnameInfo->name);
64+
$this->assertEquals($mailname->id, $mailnameInfo->id);
6465

6566
static::$_client->mail()->delete('name', $mailname->name, static::$webspace->id);
6667
}

tests/ResellerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function testGet()
4242
$this->assertEquals('John Reseller', $resellerInfo->personalName);
4343
$this->assertEquals('reseller-unit-test', $resellerInfo->login);
4444
$this->assertGreaterThan(0, count($resellerInfo->permissions));
45+
$this->assertEquals($reseller->id, $resellerInfo->id);
4546

4647
static::$_client->reseller()->delete('id', $reseller->id);
4748
}

tests/SiteTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public function testGet()
6464
$this->assertMatchesRegularExpression("/^\d{4}-\d{2}-\d{2}$/", $siteInfo->creationDate);
6565
$this->assertEquals(36, strlen($siteInfo->guid));
6666

67+
$siteGuid = $siteInfo->guid;
68+
$siteInfo = static::$_client->site()->get('guid', $siteGuid);
69+
$this->assertEquals($site->id, $siteInfo->id);
70+
6771
static::$_client->site()->delete('id', $site->id);
6872
}
6973

@@ -102,6 +106,7 @@ public function testGetAll()
102106
$this->assertCount(2, $sitesInfo);
103107
$this->assertEquals('addon.dom', $sitesInfo[0]->name);
104108
$this->assertEquals('addon.dom', $sitesInfo[0]->asciiName);
109+
$this->assertEquals($site->id, $sitesInfo[0]->id);
105110

106111
static::$_client->site()->delete('id', $site->id);
107112
static::$_client->site()->delete('id', $site2->id);

tests/SubdomainTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function testGet()
6161
$subdomainInfo = static::$_client->subdomain()->get('id', $subdomain->id);
6262
$this->assertEquals($name.'.'.$subdomainInfo->parent, $subdomainInfo->name);
6363
$this->assertTrue(false !== strpos($subdomainInfo->properties['www_root'], $name));
64+
$this->assertEquals($subdomain->id, $subdomainInfo->id);
6465

6566
static::$_client->subdomain()->delete('id', $subdomain->id);
6667
}

tests/WebspaceTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ public function testGet()
182182
$this->assertEquals($webspaceInfo->name, $webspaceInfo->asciiName);
183183
$this->assertIsArray($webspaceInfo->ipAddresses);
184184
$this->assertEquals(36, strlen($webspaceInfo->guid));
185+
$this->assertMatchesRegularExpression("/^\d{4}-\d{2}-\d{2}$/", $webspaceInfo->creationDate);
186+
$this->assertEquals($webspace->id, $webspaceInfo->id);
185187

186188
static::$_client->webspace()->delete('id', $webspace->id);
187189
}

0 commit comments

Comments
 (0)