You are here

public function HttpClientTest::testCall in HTTP Client Manager 8.2

Same name and namespace in other branches
  1. 8 tests/src/Unit/HttpClientTest.php \Drupal\Tests\http_client_manager\Unit\HttpClientTest::testCall()

Tests HttpClient::call().

@covers ::call

File

tests/src/Unit/HttpClientTest.php, line 90

Class

HttpClientTest
Class HttpClientTest.

Namespace

Drupal\Tests\http_client_manager\Unit

Code

public function testCall() {
  $result = $this->client
    ->call('FindPosts');
  $this
    ->assertNotEmpty($result);
  $this
    ->assertInstanceOf('GuzzleHttp\\Command\\Result', $result);
  $this
    ->assertGreaterThan(1, $result
    ->count());
  $result = $this->client
    ->call('FindPost', [
    'postId' => 1,
  ]);
  $this
    ->assertNotEmpty($result);
  $this
    ->assertInstanceOf('GuzzleHttp\\Command\\Result', $result);
  $result = $result
    ->toArray();
  $this
    ->assertArrayHasKey('id', $result);
  $this
    ->assertEquals(1, $result['id']);
  $this
    ->assertCount(4, $result);
  $keys = [
    'userId',
    'id',
    'title',
    'body',
  ];
  $this
    ->assertSame($keys, array_keys($result));
}