77 */
88class ClientTest extends \Test \Ease \MoleculeTest
99{
10+
1011 /**
1112 * @var Client
1213 */
@@ -19,6 +20,7 @@ class ClientTest extends \Test\Ease\MoleculeTest
1920 protected function setUp (): void
2021 {
2122 $ this ->object = new \Subreg \Client (\Ease \Shared::instanced ()->configuration );
23+ $ this ->object ->login ();
2224 }
2325
2426 /**
@@ -40,11 +42,12 @@ public function testConstructor()
4042 {
4143 $ classname = get_class ($ this ->object );
4244 // Get mock, without the constructor being called
43- $ mock = $ this ->getMockBuilder ($ classname )
44- ->disableOriginalConstructor ()
45- ->getMockForAbstractClass ();
45+ $ mock = $ this ->getMockBuilder ($ classname )
46+ ->disableOriginalConstructor ()
47+ ->getMockForAbstractClass ();
4648 $ mock ->__construct (\Ease \Shared::instanced ()->configuration );
47- $ this ->assertNotEmpty ($ mock ->token );
49+ $ this ->assertArrayHasKey ('login ' , $ this ->object ->config );
50+ $ this ->assertInstanceOf ('\SoapClient ' , $ this ->object ->soaper );
4851 }
4952
5053 /**
@@ -60,13 +63,15 @@ public function testLogBanner()
6063 */
6164 public function testCall ()
6265 {
63- $ fail = $ this ->object ->call ('NonExist ' );
66+ $ fail = $ this ->object ->call ('NonExist ' );
6467 $ this ->assertEquals (['error ' => [
6568 'errormsg ' => 'Invalid method called ' ,
6669 'errorcode ' => [
67- 'major ' => '500 ' , 'minor ' => '107 ' ]
70+ 'major ' => '500 ' ,
71+ 'minor ' => '107 '
72+ ]
6873 ]
69- ], $ fail );
74+ ], $ fail );
7075 $ success = $ this ->object ->call ('Get_Credit ' );
7176 $ this ->arrayHasKey (array_key_exists ('credit ' , $ success ));
7277 }
@@ -88,16 +93,15 @@ public function testLogError()
8893 public function testLogin ()
8994 {
9095 $ this ->assertTrue ($ this ->object ->login ());
96+ $ this ->assertNotEmpty ($ this ->object ->token );
9197 }
9298
9399 /**
94100 * @covers Subreg\Client::checkDomain
95101 */
96102 public function testCheckDomain ()
97103 {
98- $ checkResult = $ this ->object ->checkDomain ('spoje.net ' );
99- $ this ->assertTrue (array_key_exists ('name ' , $ checkResult ) && array_key_exists ('price ' ,
100- $ checkResult ));
104+ $ this ->assertIsArray ($ this ->object ->checkDomain ('php-subreg.cz ' ));
101105 }
102106
103107 /**
@@ -107,7 +111,7 @@ public function testDomainsList()
107111 {
108112 $ domainlist = $ this ->object ->domainsList ();
109113 $ this ->assertTrue (array_key_exists ('domains ' , $ domainlist ) && array_key_exists ('count ' ,
110- $ domainlist ));
114+ $ domainlist ));
111115 }
112116
113117 /**
@@ -124,21 +128,21 @@ public function testPricelist()
124128 */
125129 public function testGetPricelist ()
126130 {
127- $ pricelist = $ this ->object ->getPricelist ('??? ' );
128- $ this ->assertTrue (array_key_exists ('cz ' , $ pricelist ));
131+ $ pricelist = $ this ->object ->getPricelist ('MYPRICELIST ' );
132+ $ this ->assertTrue (array_key_exists ('error ' , $ pricelist ));
129133 }
130134
131135 /**
132136 * @covers Subreg\Client::registerDomain
133137 */
134138 public function testRegisterDomain ()
135139 {
136- $ unexistentDomain = strtolower (\Ease \Sand ::randomString ()). '.cz ' ;
140+ $ unexistentDomain = strtolower (\Ease \Functions ::randomString ()) . '.cz ' ;
137141
138142 $ nsHosts = array ("ns.spoje.net " , "ns2.spoje.net " );
139143
140144 $ result = $ this ->object ->registerDomain ($ unexistentDomain , 'G-000001 ' ,
141- 'G-000001 ' , 'G-000001 ' , 'ukulele ' , $ nsHosts );
145+ 'G-000001 ' , 'G-000001 ' , 'ukulele ' , $ nsHosts );
142146
143147 $ this ->assertTrue (array_key_exists ('orderid ' , $ result ));
144148 }
@@ -148,6 +152,23 @@ public function testRegisterDomain()
148152 */
149153 public function testRenewDomain ()
150154 {
151- $ this ->assertArrayHasKey ('orderid ' ,$ this ->object ->renewDomain ('vitexsoftware.cz ' ,1 ));
155+ $ this ->assertIsArray ($ this ->object ->renewDomain ('php-subreg.cz ' , 1 ));
156+ }
157+
158+ /**
159+ * @covers Subreg\Client::creditCorrection
160+ */
161+ public function testcreditCorrection ()
162+ {
163+ $ this ->assertIsArray ($ this ->object ->creditCorrection ('php-subreg ' , '+1 ' , 'PHPUnit Test ' ));
164+ }
165+
166+ /**
167+ * @covers Subreg\Client::infoUser
168+ */
169+ public function testinfoUser ()
170+ {
171+ $ userInfo = $ this ->object ->infoUser (1 ); // Not Exists
172+ $ this ->assertTrue (array_key_exists ('error ' , $ userInfo ));
152173 }
153174}
0 commit comments