You are here

public function HttpClientTest::testMagicMethodCall 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::testMagicMethodCall()

Tests HttpClient::__call().

@covers ::__call

File

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

Class

HttpClientTest
Class HttpClientTest.

Namespace

Drupal\Tests\http_client_manager\Unit

Code

public function testMagicMethodCall() {
  $result = $this->client
    ->findPosts();
  $this
    ->assertNotEmpty($result);
  $this
    ->assertInstanceOf('GuzzleHttp\\Command\\Result', $result);
  $this
    ->assertGreaterThan(1, count($result));
  $result = $this->client
    ->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));
}