/** * Delete a User * * @param UserObject $user * * @throws HttpClientException * * @return UserObject */ public function delete(UserObject $user) { $response = $this->send(new Request('DELETE', self::INTERCOM_BASE_URL . '/users', [], $user->format())); return $this->hydrate($user, $response->json()); }
/** * @covers ::delete() */ public function testDelete() { $user = new User(1); $clientRequest = $this->getMock('GuzzleHttp\\Message\\RequestInterface'); $response = $this->getMock('GuzzleHttp\\Message\\ResponseInterface'); $response->expects(self::once())->method('json')->will(self::returnValue($this->user)); $client = $this->getMockBuilder('GuzzleHttp\\ClientInterface')->disableOriginalConstructor()->getMock(); $client->expects(self::once())->method('createRequest')->with('DELETE', UserClient::INTERCOM_BASE_URL . '/users', ['headers' => ['Content-Type' => 'application/json', 'Accept' => 'application/json'], 'json' => $user->format(), 'query' => [], 'auth' => [$this->appId, $this->apiKey]])->will(self::returnValue($clientRequest)); $client->expects(self::once())->method('send')->with($clientRequest)->will(self::returnValue($response)); (new UserClient($this->appId, $this->apiKey, $client))->delete($user); }