@@ -20,6 +20,29 @@ public function testGetClient()
20
20
$ this ->assertEquals (123456 , $ headers ['SoftLayer_TicketInitParameters ' ]->data ->id );
21
21
}
22
22
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
+
23
46
public function testSetObjectMask ()
24
47
{
25
48
$ client = SoapClient::getClient ('SoftLayer_Ticket ' , 123456 , 'apiUsername ' , 'apiKey ' );
@@ -29,15 +52,81 @@ public function testSetObjectMask()
29
52
$ this ->assertEquals ($ mask , $ headers ['SoftLayer_ObjectMask ' ]->data ->mask );
30
53
}
31
54
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
+
32
67
public function testSetObjecFilter ()
33
68
{
34
69
$ client = SoapClient::getClient ('SoftLayer_Ticket ' , 123456 , 'apiUsername ' , 'apiKey ' );
35
70
$ filter = new \stdClass ();
36
71
$ filter ->test1 = new \stdClass ();
37
72
$ filter ->test1 ->operation = "testFilter " ;
38
73
$ client ->setObjectFilter ($ filter );
39
-
40
74
$ headers = $ client ->getHeaders ();
41
75
$ this ->assertEquals ("testFilter " , $ headers ['SoftLayer_TicketObjectFilter ' ]->data ->test1 ->operation );
42
76
}
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
+
43
131
}
132
+
0 commit comments