File tree Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 2
2
// Copyright 1999-2016. Parallels IP Holdings GmbH.
3
3
4
4
namespace PleskX \Api \Operator ;
5
+ use PleskX \Api \Struct \Subdomain as Struct ;
5
6
6
7
class Subdomain extends \PleskX \Api \Operator
7
8
{
9
+ /**
10
+ * @param array $properties
11
+ * @return Struct\Info
12
+ */
13
+ public function create ($ properties )
14
+ {
15
+ $ packet = $ this ->_client ->getPacket ();
16
+ $ info = $ packet ->addChild ($ this ->_wrapperTag )->addChild ('add ' );
8
17
18
+ foreach ($ properties as $ name => $ value ) {
19
+ $ info ->addChild ($ name , $ value );
20
+ }
21
+
22
+ $ response = $ this ->_client ->request ($ packet );
23
+ return new Struct \Info ($ response );
24
+ }
9
25
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2016. Parallels IP Holdings GmbH.
3
+
4
+ namespace PleskX \Api \Struct \Subdomain ;
5
+
6
+ class Info extends \PleskX \Api \Struct
7
+ {
8
+ /** @var integer */
9
+ public $ id ;
10
+
11
+ public function __construct ($ apiResponse )
12
+ {
13
+ $ this ->_initScalarProperties ($ apiResponse , [
14
+ 'id ' ,
15
+ ]);
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // Copyright 1999-2016. Parallels IP Holdings GmbH.
3
+
4
+ class SubdomainTest extends TestCase
5
+ {
6
+
7
+ /**
8
+ * @param string $name
9
+ * @return \PleskX\Api\Struct\Webspace\Info
10
+ */
11
+ private function _createWebspace ($ name )
12
+ {
13
+ return $ this ->_client ->webspace ()->create ([
14
+ 'name ' => $ name ,
15
+ 'ip_address ' => $ this ->_getIpAddress (),
16
+ ], [
17
+ 'ftp_login ' => 'test-login ' ,
18
+ 'ftp_password ' => 'test-password ' ,
19
+ ]);
20
+ }
21
+
22
+ /**
23
+ * @param string $name
24
+ * @param string $webspaceName
25
+ * @return \PleskX\Api\Struct\Subdomain\Info
26
+ */
27
+ private function _createSubdomain ($ name , $ webspaceName )
28
+ {
29
+ return $ this ->_client ->subdomain ()->create ([
30
+ 'parent ' => $ webspaceName ,
31
+ 'name ' => $ name ,
32
+ ]);
33
+ }
34
+
35
+ public function testCreate ()
36
+ {
37
+ $ webspaceName = 'example.tld ' ;
38
+ $ webspace = $ this ->_createWebspace ($ webspaceName );
39
+ $ subdomain = $ this ->_createSubdomain ('sub ' , $ webspaceName );
40
+
41
+ $ this ->assertInternalType ('integer ' , $ subdomain ->id );
42
+ $ this ->assertGreaterThan (0 , $ subdomain ->id );
43
+
44
+ $ this ->_client ->webspace ()->delete ('id ' , $ webspace ->id );
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments