88class DatabaseTest extends AbstractTestCase
99{
1010 private static \PleskX \Api \Struct \Webspace \Info $ webspace ;
11+ private static \PleskX \Api \Struct \DatabaseServer \Info $ databaseServer ;
1112
1213 public static function setUpBeforeClass (): void
1314 {
1415 parent ::setUpBeforeClass ();
1516 static ::$ webspace = static ::createWebspace ();
17+ static ::$ databaseServer = static ::$ client ->databaseServer ()->getDefault ('mysql ' );
1618 }
1719
1820 public function testCreate ()
1921 {
2022 $ database = $ this ->createDatabase ([
2123 'webspace-id ' => static ::$ webspace ->id ,
2224 'name ' => 'test1 ' ,
23- 'type ' => ' mysql ' ,
24- 'db-server-id ' => 1 ,
25+ 'type ' => static :: $ databaseServer -> type ,
26+ 'db-server-id ' => static :: $ databaseServer -> id ,
2527 ]);
2628 static ::$ client ->database ()->delete ('id ' , $ database ->id );
2729 }
@@ -31,8 +33,8 @@ public function testCreateUser()
3133 $ database = $ this ->createDatabase ([
3234 'webspace-id ' => static ::$ webspace ->id ,
3335 'name ' => 'test1 ' ,
34- 'type ' => ' mysql ' ,
35- 'db-server-id ' => 1 ,
36+ 'type ' => static :: $ databaseServer -> type ,
37+ 'db-server-id ' => static :: $ databaseServer -> id ,
3638 ]);
3739 $ user = $ this ->createUser ([
3840 'db-id ' => $ database ->id ,
@@ -48,8 +50,8 @@ public function testUpdateUser()
4850 $ database = $ this ->createDatabase ([
4951 'webspace-id ' => static ::$ webspace ->id ,
5052 'name ' => 'test1 ' ,
51- 'type ' => ' mysql ' ,
52- 'db-server-id ' => 1 ,
53+ 'type ' => static :: $ databaseServer -> type ,
54+ 'db-server-id ' => static :: $ databaseServer -> id ,
5355 ]);
5456 $ user = $ this ->createUser ([
5557 'db-id ' => $ database ->id ,
@@ -71,15 +73,15 @@ public function testGetById()
7173 $ database = $ this ->createDatabase ([
7274 'webspace-id ' => static ::$ webspace ->id ,
7375 'name ' => 'test1 ' ,
74- 'type ' => ' mysql ' ,
75- 'db-server-id ' => 1 ,
76+ 'type ' => static :: $ databaseServer -> type ,
77+ 'db-server-id ' => static :: $ databaseServer -> id ,
7678 ]);
7779
7880 $ db = static ::$ client ->database ()->get ('id ' , $ database ->id );
7981 $ this ->assertEquals ('test1 ' , $ db ->name );
80- $ this ->assertEquals (' mysql ' , $ db ->type );
82+ $ this ->assertEquals (static :: $ databaseServer -> type , $ db ->type );
8183 $ this ->assertEquals (static ::$ webspace ->id , $ db ->webspaceId );
82- $ this ->assertEquals (1 , $ db ->dbServerId );
84+ $ this ->assertEquals (static :: $ databaseServer -> id , $ db ->dbServerId );
8385
8486 static ::$ client ->database ()->delete ('id ' , $ database ->id );
8587 }
@@ -89,20 +91,20 @@ public function testGetAllByWebspaceId()
8991 $ db1 = $ this ->createDatabase ([
9092 'webspace-id ' => static ::$ webspace ->id ,
9193 'name ' => 'test1 ' ,
92- 'type ' => ' mysql ' ,
93- 'db-server-id ' => 1 ,
94+ 'type ' => static :: $ databaseServer -> type ,
95+ 'db-server-id ' => static :: $ databaseServer -> id ,
9496 ]);
9597 $ db2 = $ this ->createDatabase ([
9698 'webspace-id ' => static ::$ webspace ->id ,
9799 'name ' => 'test2 ' ,
98- 'type ' => ' mysql ' ,
99- 'db-server-id ' => 1 ,
100+ 'type ' => static :: $ databaseServer -> type ,
101+ 'db-server-id ' => static :: $ databaseServer -> id ,
100102 ]);
101103 $ databases = static ::$ client ->database ()->getAll ('webspace-id ' , static ::$ webspace ->id );
102104 $ this ->assertEquals ('test1 ' , $ databases [0 ]->name );
103105 $ this ->assertEquals ('test2 ' , $ databases [1 ]->name );
104106 $ this ->assertEquals (static ::$ webspace ->id , $ databases [0 ]->webspaceId );
105- $ this ->assertEquals (1 , $ databases [1 ]->dbServerId );
107+ $ this ->assertEquals (static :: $ databaseServer -> id , $ databases [1 ]->dbServerId );
106108
107109 static ::$ client ->database ()->delete ('id ' , $ db1 ->id );
108110 static ::$ client ->database ()->delete ('id ' , $ db2 ->id );
@@ -113,8 +115,8 @@ public function testGetUserById()
113115 $ database = $ this ->createDatabase ([
114116 'webspace-id ' => static ::$ webspace ->id ,
115117 'name ' => 'test1 ' ,
116- 'type ' => ' mysql ' ,
117- 'db-server-id ' => 1 ,
118+ 'type ' => static :: $ databaseServer -> type ,
119+ 'db-server-id ' => static :: $ databaseServer -> id ,
118120 ]);
119121
120122 $ user = $ this ->createUser ([
@@ -136,14 +138,14 @@ public function testGetAllUsersByDbId()
136138 $ db1 = $ this ->createDatabase ([
137139 'webspace-id ' => static ::$ webspace ->id ,
138140 'name ' => 'test1 ' ,
139- 'type ' => ' mysql ' ,
140- 'db-server-id ' => 1 ,
141+ 'type ' => static :: $ databaseServer -> type ,
142+ 'db-server-id ' => static :: $ databaseServer -> id ,
141143 ]);
142144 $ db2 = $ this ->createDatabase ([
143145 'webspace-id ' => static ::$ webspace ->id ,
144146 'name ' => 'test2 ' ,
145- 'type ' => ' mysql ' ,
146- 'db-server-id ' => 1 ,
147+ 'type ' => static :: $ databaseServer -> type ,
148+ 'db-server-id ' => static :: $ databaseServer -> id ,
147149 ]);
148150 $ user1 = $ this ->createUser ([
149151 'db-id ' => $ db1 ->id ,
@@ -180,8 +182,8 @@ public function testDelete()
180182 $ database = $ this ->createDatabase ([
181183 'webspace-id ' => static ::$ webspace ->id ,
182184 'name ' => 'test1 ' ,
183- 'type ' => ' mysql ' ,
184- 'db-server-id ' => 1 ,
185+ 'type ' => static :: $ databaseServer -> type ,
186+ 'db-server-id ' => static :: $ databaseServer -> id ,
185187 ]);
186188 $ result = static ::$ client ->database ()->delete ('id ' , $ database ->id );
187189 $ this ->assertTrue ($ result );
@@ -192,8 +194,8 @@ public function testDeleteUser()
192194 $ database = $ this ->createDatabase ([
193195 'webspace-id ' => static ::$ webspace ->id ,
194196 'name ' => 'test1 ' ,
195- 'type ' => ' mysql ' ,
196- 'db-server-id ' => 1 ,
197+ 'type ' => static :: $ databaseServer -> type ,
198+ 'db-server-id ' => static :: $ databaseServer -> id ,
197199 ]);
198200 $ user = $ this ->createUser ([
199201 'db-id ' => $ database ->id ,
0 commit comments