@@ -46,16 +46,17 @@ public function testDelete()
4646
4747 public function testRequestCreateWebspace ()
4848 {
49- $ id = uniqid ();
50- $ password = base64_encode (time ());
51- $ name = "d {$ id }.test " ;
52-
53- $ handler = static ::$ _client ->phpHandler ()->get (null , null );
49+ $ handlers = static ::$ _client ->phpHandler ()->getAll ();
50+ $ enabledHandlers = array_filter ($ handlers , function ($ handler ) {
51+ return $ handler ->handlerStatus !== 'disabled ' ;
52+ });
53+ $ this ->assertGreaterThan (0 , count ($ enabledHandlers ));
54+ $ handler = current ($ enabledHandlers );
5455
5556 $ request = [
5657 'add ' => [
5758 'gen_setup ' => [
58- 'name ' => $ name ,
59+ 'name ' => ' webspace-test-full.test ' ,
5960 'htype ' => 'vrt_hst ' ,
6061 'status ' => '0 ' ,
6162 'ip_address ' => [static ::_getIpAddress ()],
@@ -69,11 +70,11 @@ public function testRequestCreateWebspace()
6970 ],
7071 [
7172 'name ' => 'ftp_login ' ,
72- 'value ' => " u { $ id }" ,
73+ 'value ' => ' testuser ' ,
7374 ],
7475 [
7576 'name ' => 'ftp_password ' ,
76- 'value ' => $ password ,
77+ 'value ' => ' test-PWD*1 ' ,
7778 ],
7879 ],
7980 'ip_address ' => static ::_getIpAddress (),
@@ -120,17 +121,7 @@ public function testRequestCreateWebspace()
120121 ],
121122 ];
122123
123- try {
124- $ webspace = static ::$ _client ->webspace ()->request ($ request );
125- } catch (\Exception $ e ) {
126- try {
127- $ webspaceInfo = static ::$ _client ->webspace ()->get ('name ' , $ name );
128- static ::$ _client ->webspace ()->delete ('guid ' , $ webspaceInfo ->guid );
129- } catch (\Exception $ e ) {
130- }
131-
132- $ this ->fail ($ e ->getMessage ());
133- }
124+ $ webspace = static ::$ _client ->webspace ()->request ($ request );
134125
135126 $ this ->assertGreaterThan (0 , $ webspace ->id );
136127
@@ -142,8 +133,8 @@ public function testGet()
142133 $ webspace = static ::_createWebspace ();
143134 $ webspaceInfo = static ::$ _client ->webspace ()->get ('id ' , $ webspace ->id );
144135
136+ $ this ->assertInstanceOf (\PleskX \Api \Struct \Webspace \GeneralInfo::class, $ webspaceInfo );
145137 $ this ->assertNotEmpty ($ webspaceInfo ->name );
146138 $ this ->assertEquals (0 , $ webspaceInfo ->realSize );
147-
148139 }
149140}
0 commit comments