You are here

public function HttpClientTest::testCall in HTTP Client Manager 8

Same name and namespace in other branches
  1. 8.2 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 88

Class

HttpClientTest
Class HttpClientTest.

Namespace

Drupal\Tests\http_client_manager\Unit

Code

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