@@ -59,7 +59,7 @@ protected function setUp(): void
59
59
->getMockForAbstractClass ();
60
60
61
61
$ this ->configMock = $ this ->getMockBuilder (Config::class)
62
- ->setMethods (['getNewRelicApiUrl ' , 'getNewRelicApiKey ' , 'getNewRelicAppName ' , ' getNewRelicAppId ' ])
62
+ ->setMethods (['getNewRelicApiUrl ' , 'getNewRelicApiKey ' , 'getNewRelicAppId ' ])
63
63
->disableOriginalConstructor ()
64
64
->getMock ();
65
65
@@ -109,10 +109,6 @@ public function testSetDeploymentRequestOk()
109
109
->method ('getNewRelicApiKey ' )
110
110
->willReturn ($ data ['api_key ' ]);
111
111
112
- $ this ->configMock ->expects ($ this ->once ())
113
- ->method ('getNewRelicAppName ' )
114
- ->willReturn ($ data ['app_name ' ]);
115
-
116
112
$ this ->configMock ->expects ($ this ->once ())
117
113
->method ('getNewRelicAppId ' )
118
114
->willReturn ($ data ['app_id ' ]);
@@ -130,7 +126,7 @@ public function testSetDeploymentRequestOk()
130
126
->method ('create ' )
131
127
->willReturn ($ this ->zendClientMock );
132
128
133
- $ this ->assertIsString ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ]));
129
+ $ this ->assertIsString ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ], $ data [ ' revision ' ] ));
134
130
}
135
131
136
132
/**
@@ -170,10 +166,6 @@ public function testSetDeploymentBadStatus()
170
166
->method ('getNewRelicApiKey ' )
171
167
->willReturn ($ data ['api_key ' ]);
172
168
173
- $ this ->configMock ->expects ($ this ->once ())
174
- ->method ('getNewRelicAppName ' )
175
- ->willReturn ($ data ['app_name ' ]);
176
-
177
169
$ this ->configMock ->expects ($ this ->once ())
178
170
->method ('getNewRelicAppId ' )
179
171
->willReturn ($ data ['app_id ' ]);
@@ -191,7 +183,7 @@ public function testSetDeploymentBadStatus()
191
183
->method ('create ' )
192
184
->willReturn ($ this ->zendClientMock );
193
185
194
- $ this ->assertIsBool ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ]));
186
+ $ this ->assertIsBool ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ], $ data [ ' revision ' ] ));
195
187
}
196
188
197
189
/**
@@ -229,10 +221,6 @@ public function testSetDeploymentRequestFail()
229
221
->method ('getNewRelicApiKey ' )
230
222
->willReturn ($ data ['api_key ' ]);
231
223
232
- $ this ->configMock ->expects ($ this ->once ())
233
- ->method ('getNewRelicAppName ' )
234
- ->willReturn ($ data ['app_name ' ]);
235
-
236
224
$ this ->configMock ->expects ($ this ->once ())
237
225
->method ('getNewRelicAppId ' )
238
226
->willReturn ($ data ['app_id ' ]);
@@ -246,7 +234,7 @@ public function testSetDeploymentRequestFail()
246
234
->method ('create ' )
247
235
->willReturn ($ this ->zendClientMock );
248
236
249
- $ this ->assertIsBool ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ]));
237
+ $ this ->assertIsBool ($ this ->model ->setDeployment ($ data ['description ' ], $ data ['change ' ], $ data ['user ' ], $ data [ ' revision ' ] ));
250
238
}
251
239
252
240
/**
@@ -258,23 +246,26 @@ private function getDataVariables()
258
246
$ change = 'flush the cache username ' ;
259
247
$ user = 'username ' ;
260
248
$ uri = 'https://example.com/listener ' ;
261
- $ selfUri = 'https://api.newrelic.com/deployments.xml ' ;
249
+ $ selfUri = 'https://api.newrelic.com/v2/applications/%s/ deployments.json ' ;
262
250
$ apiKey = '1234 ' ;
263
251
$ appName = 'app_name ' ;
264
252
$ appId = 'application_id ' ;
265
253
$ method = ZendClient::POST ;
266
- $ headers = ['x-api-key ' => $ apiKey ];
254
+ $ headers = ['Api-Key ' => $ apiKey, ' Content-Type ' => ' application/json ' ];
267
255
$ responseBody = 'Response body content ' ;
268
256
$ statusOk = '200 ' ;
269
257
$ statusBad = '401 ' ;
258
+ $ revision = 'f81d42327219e17b1427096c354e9b8209939d4dd586972f12f0352f8343b91b ' ;
270
259
$ params = [
271
- 'deployment[app_name] ' => $ appName ,
272
- 'deployment[application_id] ' => $ appId ,
273
- 'deployment[description] ' => $ description ,
274
- 'deployment[changelog] ' => $ change ,
275
- 'deployment[user] ' => $ user
260
+ 'deployment ' => [
261
+ 'description ' => $ description ,
262
+ 'changelog ' => $ change ,
263
+ 'user ' => $ user ,
264
+ 'revision ' => $ revision
265
+ ]
276
266
];
277
267
268
+ $ selfUri = sprintf ($ selfUri , $ appId );
278
269
return ['description ' => $ description ,
279
270
'change ' => $ change ,
280
271
'user ' => $ user ,
@@ -288,7 +279,8 @@ private function getDataVariables()
288
279
'status_ok ' => $ statusOk ,
289
280
'status_bad ' => $ statusBad ,
290
281
'response_body ' => $ responseBody ,
291
- 'params ' => $ params
282
+ 'params ' => $ params ,
283
+ 'revision ' => $ revision
292
284
];
293
285
}
294
286
}
0 commit comments