@@ -20,6 +20,29 @@ public function testGetClient()
2020 $ this ->assertEquals (123456 , $ headers ['SoftLayer_TicketInitParameters ' ]->data ->id );
2121 }
2222
23+ public function testGetClientDefaults ()
24+ {
25+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' );
26+ $ headers = $ client ->getHeaders ();
27+ $ this ->assertEquals ('set me ' , $ headers ['authenticate ' ]->data ->username );
28+ $ this ->assertEquals ('set me ' , $ headers ['authenticate ' ]->data ->apiKey );
29+ $ this ->assertFalse (array_key_exists ('SoftLayer_TicketInitParameters ' , $ headers ));
30+ }
31+
32+ public function testGetClientNoService ()
33+ {
34+ $ this ->expectException (\Exception::class);
35+ $ this ->expectExceptionMessage ('Please provide a SoftLayer API service name. ' );
36+ $ client = SoapClient::getClient ('' , 123456 , 'apiUsername ' , 'apiKey ' );
37+ }
38+
39+ public function testGetClientNoEndpoint ()
40+ {
41+ $ this ->expectException (\Exception::class);
42+ $ this ->expectExceptionMessage ('Please provide a valid API endpoint. ' );
43+ $ client = SoapClient::getClient ('SoftLayer_Account ' , 123456 , 'apiUsername ' , 'apiKey ' , $ endpointUrl =' ' );
44+ }
45+
2346 public function testSetObjectMask ()
2447 {
2548 $ client = SoapClient::getClient ('SoftLayer_Ticket ' , 123456 , 'apiUsername ' , 'apiKey ' );
@@ -29,15 +52,81 @@ public function testSetObjectMask()
2952 $ this ->assertEquals ($ mask , $ headers ['SoftLayer_ObjectMask ' ]->data ->mask );
3053 }
3154
55+ public function testSetObjectMaskClass ()
56+ {
57+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' , 123456 , 'apiUsername ' , 'apiKey ' );
58+ $ mask = new \SoftLayer \Common \ObjectMask ();
59+ $ mask ->id ;
60+ $ mask ->username ;
61+ $ client ->setObjectMask ($ mask );
62+ $ headers = $ client ->getHeaders ();
63+
64+ $ this ->assertEquals ($ mask , $ headers ['SoftLayer_TicketObjectMask ' ]->data ->mask );
65+ }
66+
3267 public function testSetObjecFilter ()
3368 {
3469 $ client = SoapClient::getClient ('SoftLayer_Ticket ' , 123456 , 'apiUsername ' , 'apiKey ' );
3570 $ filter = new \stdClass ();
3671 $ filter ->test1 = new \stdClass ();
3772 $ filter ->test1 ->operation = "testFilter " ;
3873 $ client ->setObjectFilter ($ filter );
39-
4074 $ headers = $ client ->getHeaders ();
4175 $ this ->assertEquals ("testFilter " , $ headers ['SoftLayer_TicketObjectFilter ' ]->data ->test1 ->operation );
4276 }
77+
78+ public function testSetAuthentication ()
79+ {
80+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' );
81+ $ headers = $ client ->getHeaders ();
82+ $ this ->assertEquals ('set me ' , $ headers ['authenticate ' ]->data ->username );
83+ $ this ->assertEquals ('set me ' , $ headers ['authenticate ' ]->data ->apiKey );
84+
85+ $ this ->expectException (\Exception::class);
86+ $ this ->expectExceptionMessage ('Please provide a SoftLayer API key. ' );
87+ $ client ->setAuthentication ('username1 ' , '' );
88+
89+ $ this ->expectException (\Exception::class);
90+ $ this ->expectExceptionMessage ('Please provide a SoftLayer API username. ' );
91+ $ client ->setAuthentication (null , 'apikey2 ' );
92+
93+ $ client ->setAuthentication ('username1 ' , 'apikey2 ' );
94+ $ this ->assertEquals ('username1 ' , $ headers ['authenticate ' ]->data ->username );
95+ $ this ->assertEquals ('apikey2 ' , $ headers ['authenticate ' ]->data ->apiKey );
96+ }
97+
98+ public function testRemoveHeader ()
99+ {
100+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' );
101+ $ headers = $ client ->getHeaders ();
102+ $ this ->assertTrue (array_key_exists ('authenticate ' , $ headers ));
103+ $ client ->removeHeader ('authenticate ' );
104+ $ headers = $ client ->getHeaders ();
105+ $ this ->assertFalse (array_key_exists ('authenticate ' , $ headers ));
106+ }
107+
108+ public function testSetInitParameters ()
109+ {
110+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' );
111+ $ headers = $ client ->getHeaders ();
112+ $ this ->assertFalse (array_key_exists ('SoftLayer_TicketInitParameters ' , $ headers ));;
113+ $ client ->setInitParameter (999 );
114+ $ headers = $ client ->getHeaders ();
115+ $ this ->assertTrue (array_key_exists ('authenticate ' , $ headers ));
116+ $ this ->assertEquals (999 , $ headers ['SoftLayer_TicketInitParameters ' ]->data ->id );
117+ }
118+
119+ public function testSetResultLimit ()
120+ {
121+ $ client = SoapClient::getClient ('SoftLayer_Ticket ' );
122+ $ headers = $ client ->getHeaders ();
123+ $ this ->assertFalse (array_key_exists ('resultLimit ' , $ headers ));;
124+ $ client ->setResultLimit (111 , 999 );
125+ $ headers = $ client ->getHeaders ();
126+ $ this ->assertTrue (array_key_exists ('resultLimit ' , $ headers ));
127+ $ this ->assertEquals (111 , $ headers ['resultLimit ' ]->data ->limit );
128+ $ this ->assertEquals (999 , $ headers ['resultLimit ' ]->data ->offset );
129+ }
130+
43131}
132+
0 commit comments