Пример #1
0
 public function testAddCustomAttributes()
 {
     $user = new User(1, 'FréDériC@bar.fr');
     $user->addCustomAttributes('foo', 'bar');
     $this->assertEquals('bar', $user->getCustomAttributes('foo'));
     $this->assertEquals(['foo' => 'bar'], $user->getCustomAttributes());
     $this->assertEquals(['foo' => 'bar'], $user->getCustomAttributes('zzz'));
     $this->assertEquals('frédéric@bar.fr', $user->getEmail());
     $this->assertTrue($user->hasCustomAttributes('foo'));
     $this->assertFalse($user->hasCustomAttributes('zzz'));
 }
Пример #2
0
 /**
  * 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());
 }
Пример #3
0
 /**
  * @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);
 }