You are here

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

Tests HttpClient::__call().

@covers ::__call

File

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

Class

HttpClientTest
Class HttpClientTest.

Namespace

Drupal\Tests\http_client_manager\Unit

Code

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