@@ -85,6 +85,27 @@ function testExceptionFromServiceMethod(){
85
85
$ client = new Client ();
86
86
$ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/exception ' );
87
87
88
+ $ isException = false ;
89
+ try {
90
+ $ client ->send ($ request );
91
+ }catch (ServerErrorResponseException $ e ){
92
+ $ response = $ e ->getResponse ();
93
+ $ this ->assertEquals (500 , $ response ->getStatusCode ());
94
+ $ this ->assertEquals ("Internal Server Error " , $ response ->getReasonPhrase ());
95
+ $ this ->assertEquals ("" , $ response ->getBody (true ));
96
+
97
+ // validate log
98
+ $ this ->assertContainsAndClearLog ('Testing Exception in Service Method ' );
99
+
100
+ $ isException = true ;
101
+ }
102
+ $ this ->assertTrue ($ isException );
103
+ }
104
+
105
+ function testPlatformExceptionFromServiceMethod (){
106
+ $ client = new Client ();
107
+ $ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/exception/platform-exception ' );
108
+
88
109
$ isException = false ;
89
110
try {
90
111
$ client ->send ($ request );
@@ -102,6 +123,69 @@ function testExceptionFromServiceMethod(){
102
123
$ this ->assertTrue ($ isException );
103
124
}
104
125
126
+ function testInternalServerErrorFromServiceMethod (){
127
+ $ client = new Client ();
128
+ $ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/exception/internal-server-error ' );
129
+
130
+ $ isException = false ;
131
+ try {
132
+ $ client ->send ($ request );
133
+ }catch (ServerErrorResponseException $ e ){
134
+ $ response = $ e ->getResponse ();
135
+ $ this ->assertEquals (500 , $ response ->getStatusCode ());
136
+ $ this ->assertEquals ("Internal Server Error " , $ response ->getReasonPhrase ());
137
+ $ this ->assertEquals ("" , $ response ->getBody (true ));
138
+
139
+ // validate log
140
+ $ this ->assertContainsAndClearLog ('Testing Uncaught internalServerError in Service ' );
141
+
142
+ $ isException = true ;
143
+ }
144
+ $ this ->assertTrue ($ isException );
145
+ }
146
+
147
+ function testDataNotFoundExceptionFromServiceMethod (){
148
+ $ client = new Client ();
149
+ $ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/exception/data-not-found-exception ' );
150
+
151
+ $ isException = false ;
152
+ try {
153
+ $ client ->send ($ request );
154
+ }catch (ClientErrorResponseException $ e ){
155
+ $ response = $ e ->getResponse ();
156
+ $ this ->assertEquals (404 , $ response ->getStatusCode ());
157
+ $ this ->assertEquals ("Not Found " , $ response ->getReasonPhrase ());
158
+ $ this ->assertEquals ("" , $ response ->getBody (true ));
159
+
160
+ // validate log
161
+ $ this ->assertContainsAndClearLog ('[H][404][::1][/test/route/exception/data-not-found-exception] Not Found ' );
162
+
163
+ $ isException = true ;
164
+ }
165
+ $ this ->assertTrue ($ isException );
166
+ }
167
+
168
+ function testNoAccessExceptionFromServiceMethod (){
169
+ $ client = new Client ();
170
+ $ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/exception/no-access-exception ' );
171
+
172
+ $ isException = false ;
173
+ try {
174
+ $ client ->send ($ request );
175
+ }catch (ClientErrorResponseException $ e ){
176
+ $ response = $ e ->getResponse ();
177
+ $ this ->assertEquals (401 , $ response ->getStatusCode ());
178
+ $ this ->assertEquals ("Unauthorized " , $ response ->getReasonPhrase ());
179
+ $ this ->assertEquals ("" , $ response ->getBody (true ));
180
+
181
+ // validate log
182
+ $ this ->assertContainsAndClearLog ('[H][401][::1][/test/route/exception/no-access-exception] Unauthorized ' );
183
+
184
+ $ isException = true ;
185
+ }
186
+ $ this ->assertTrue ($ isException );
187
+ }
188
+
105
189
function testPathParams (){
106
190
$ client = new Client ();
107
191
$ request = $ client ->get (APP_DOMAIN .'/ ' .APP_PATH .'/test/route/myParam1/path/myParam2 ' );
0 commit comments