Skip to content

Commit ec9861d

Browse files
Merge pull request plesk#22 from vbaranovskiy-plesk/master
Add property node to subdomain's creation
2 parents 5e8b831 + ce2e3b2 commit ec9861d

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/PleskX/Api/Operator/Subdomain.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ public function create($properties)
1616
$info = $packet->addChild($this->_wrapperTag)->addChild('add');
1717

1818
foreach ($properties as $name => $value) {
19+
if (is_array($value)) {
20+
foreach ($value as $propertyName => $propertyValue) {
21+
$property = $info->addChild($name);
22+
$property->addChild('name', $propertyName);
23+
$property->addChild('value', $propertyValue);
24+
}
25+
continue;
26+
}
1927
$info->addChild($name, $value);
2028
}
2129

tests/SubdomainTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ private function _createSubdomain($name)
3030
return static::$_client->subdomain()->create([
3131
'parent' => 'example.dom',
3232
'name' => $name,
33+
'property' => [
34+
'www_root' => $name,
35+
]
3336
]);
3437
}
3538

@@ -53,23 +56,29 @@ public function testDelete()
5356

5457
public function testGet()
5558
{
56-
$subdomain = $this->_createSubdomain('sub');
59+
$name = 'sub';
60+
$subdomain = $this->_createSubdomain($name);
5761

5862
$subdomainInfo = static::$_client->subdomain()->get('id', $subdomain->id);
59-
$this->assertEquals('sub.' . $subdomainInfo->parent, $subdomainInfo->name);
63+
$this->assertEquals($name . '.' . $subdomainInfo->parent, $subdomainInfo->name);
64+
$this->assertTrue(false !== strpos($subdomainInfo->properties['www_root'], $name));
6065

6166
static::$_client->subdomain()->delete('id', $subdomain->id);
6267
}
6368

6469
public function testGetAll()
6570
{
66-
$subdomain = $this->_createSubdomain('sub');
67-
$subdomain2 = $this->_createSubdomain('sub2');
71+
$name = 'sub';
72+
$name2 = 'sub2';
73+
$subdomain = $this->_createSubdomain($name);
74+
$subdomain2 = $this->_createSubdomain($name2);
6875

6976
$subdomainsInfo = static::$_client->subdomain()->getAll();
7077
$this->assertCount(2, $subdomainsInfo);
71-
$this->assertEquals('sub.' . $subdomainsInfo[0]->parent, $subdomainsInfo[0]->name);
72-
$this->assertEquals('sub2.' . $subdomainsInfo[1]->parent, $subdomainsInfo[1]->name);
78+
$this->assertEquals($name . '.' . $subdomainsInfo[0]->parent, $subdomainsInfo[0]->name);
79+
$this->assertTrue(false !== strpos($subdomainsInfo[0]->properties['www_root'], $name));
80+
$this->assertEquals($name2 . '.' . $subdomainsInfo[1]->parent, $subdomainsInfo[1]->name);
81+
$this->assertTrue(false !== strpos($subdomainsInfo[1]->properties['www_root'], $name2));
7382

7483
static::$_client->subdomain()->delete('id', $subdomain->id);
7584
static::$_client->subdomain()->delete('id', $subdomain2->id);

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected static function _createWebspace($name)
4545
'ip_address' => static::_getIpAddress(),
4646
], [
4747
'ftp_login' => 'test-login',
48-
'ftp_password' => 'test-password',
48+
'ftp_password' => 'TEST-password',
4949
]);
5050
}
5151

0 commit comments

Comments
 (0)