/** * Tests client request with Ok status * * @return void */ public function testSendRequestStatusOk() { $json = '{"eventType":"Cron","appName":"app_name","appId":"app_id"}'; $statusOk = '200'; $uri = 'https://example.com/listener'; $method = ZendClient::POST; $headers = ['X-Insert-Key' => 'insert_key_value', 'Content-Type' => 'application/json']; $accId = 'acc_id'; $appId = 'app_id'; $appName = 'app_name'; $insightApiKey = 'insert_key_value'; $this->model->addData(['eventType' => 'Cron']); $this->zendClientMock->expects($this->once())->method('setUri')->with($uri)->willReturnSelf(); $this->zendClientMock->expects($this->once())->method('setMethod')->with($method)->willReturnSelf(); $this->zendClientMock->expects($this->once())->method('setHeaders')->with($headers)->willReturnSelf(); $this->zendClientMock->expects($this->once())->method('setRawData')->with($json)->willReturnSelf(); $this->configMock->expects($this->once())->method('getNewRelicAccountId')->willReturn($accId); $this->configMock->expects($this->once())->method('getInsightsApiUrl')->willReturn($uri); $this->configMock->expects($this->once())->method('getInsightsInsertKey')->willReturn($insightApiKey); $this->configMock->expects($this->once())->method('getNewRelicAppName')->willReturn($appName); $this->configMock->expects($this->once())->method('getNewRelicAppId')->willReturn($appId); $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($json); $zendHttpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->getMock(); $zendHttpResponseMock->expects($this->any())->method('getStatus')->willReturn($statusOk); $this->zendClientMock->expects($this->once())->method('request')->willReturn($zendHttpResponseMock); $this->zendClientFactoryMock->expects($this->once())->method('create')->willReturn($this->zendClientMock); $this->assertInternalType('bool', $this->model->sendRequest()); }