@@ -59,7 +59,7 @@ protected function setUp(): void
5959 ->getMockForAbstractClass ();
6060
6161 $ this ->configMock = $ this ->getMockBuilder (Config::class)
62- ->setMethods (['getNewRelicApiUrl ' , 'getNewRelicApiKey ' , 'getNewRelicAppName ' , ' getNewRelicAppId ' ])
62+ ->setMethods (['getNewRelicApiUrl ' , 'getNewRelicApiKey ' , 'getNewRelicAppId ' ])
6363 ->disableOriginalConstructor ()
6464 ->getMock ();
6565
@@ -109,10 +109,6 @@ public function testSetDeploymentRequestOk()
109109 ->method ('getNewRelicApiKey ' )
110110 ->willReturn ($ data ['api_key ' ]);
111111
112- $ this ->configMock ->expects ($ this ->once ())
113- ->method ('getNewRelicAppName ' )
114- ->willReturn ($ data ['app_name ' ]);
115-
116112 $ this ->configMock ->expects ($ this ->once ())
117113 ->method ('getNewRelicAppId ' )
118114 ->willReturn ($ data ['app_id ' ]);
@@ -130,7 +126,7 @@ public function testSetDeploymentRequestOk()
130126 ->method ('create ' )
131127 ->willReturn ($ this ->zendClientMock );
132128
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 ' ] ));
134130 }
135131
136132 /**
@@ -170,10 +166,6 @@ public function testSetDeploymentBadStatus()
170166 ->method ('getNewRelicApiKey ' )
171167 ->willReturn ($ data ['api_key ' ]);
172168
173- $ this ->configMock ->expects ($ this ->once ())
174- ->method ('getNewRelicAppName ' )
175- ->willReturn ($ data ['app_name ' ]);
176-
177169 $ this ->configMock ->expects ($ this ->once ())
178170 ->method ('getNewRelicAppId ' )
179171 ->willReturn ($ data ['app_id ' ]);
@@ -191,7 +183,7 @@ public function testSetDeploymentBadStatus()
191183 ->method ('create ' )
192184 ->willReturn ($ this ->zendClientMock );
193185
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 ' ] ));
195187 }
196188
197189 /**
@@ -229,10 +221,6 @@ public function testSetDeploymentRequestFail()
229221 ->method ('getNewRelicApiKey ' )
230222 ->willReturn ($ data ['api_key ' ]);
231223
232- $ this ->configMock ->expects ($ this ->once ())
233- ->method ('getNewRelicAppName ' )
234- ->willReturn ($ data ['app_name ' ]);
235-
236224 $ this ->configMock ->expects ($ this ->once ())
237225 ->method ('getNewRelicAppId ' )
238226 ->willReturn ($ data ['app_id ' ]);
@@ -246,7 +234,7 @@ public function testSetDeploymentRequestFail()
246234 ->method ('create ' )
247235 ->willReturn ($ this ->zendClientMock );
248236
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 ' ] ));
250238 }
251239
252240 /**
@@ -258,23 +246,26 @@ private function getDataVariables()
258246 $ change = 'flush the cache username ' ;
259247 $ user = 'username ' ;
260248 $ uri = 'https://example.com/listener ' ;
261- $ selfUri = 'https://api.newrelic.com/deployments.xml ' ;
249+ $ selfUri = 'https://api.newrelic.com/v2/applications/%s/ deployments.json ' ;
262250 $ apiKey = '1234 ' ;
263251 $ appName = 'app_name ' ;
264252 $ appId = 'application_id ' ;
265253 $ method = ZendClient::POST ;
266- $ headers = ['x-api-key ' => $ apiKey ];
254+ $ headers = ['Api-Key ' => $ apiKey, ' Content-Type ' => ' application/json ' ];
267255 $ responseBody = 'Response body content ' ;
268256 $ statusOk = '200 ' ;
269257 $ statusBad = '401 ' ;
258+ $ revision = 'f81d42327219e17b1427096c354e9b8209939d4dd586972f12f0352f8343b91b ' ;
270259 $ 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+ ]
276266 ];
277267
268+ $ selfUri = sprintf ($ selfUri , $ appId );
278269 return ['description ' => $ description ,
279270 'change ' => $ change ,
280271 'user ' => $ user ,
@@ -288,7 +279,8 @@ private function getDataVariables()
288279 'status_ok ' => $ statusOk ,
289280 'status_bad ' => $ statusBad ,
290281 'response_body ' => $ responseBody ,
291- 'params ' => $ params
282+ 'params ' => $ params ,
283+ 'revision ' => $ revision
292284 ];
293285 }
294286}
0 commit comments