You are here

public function TestFrameworkKernelTest::testInlineResponseQueue in Apigee Edge 8

Tests that API responses can be queued.

File

tests/src/Kernel/TestFrameworkKernelTest.php, line 100

Class

TestFrameworkKernelTest
Tests the testing framework for testing offline.

Namespace

Drupal\Tests\apigee_edge\Kernel

Code

public function testInlineResponseQueue() {
  if ($this->integration_enabled) {
    static::markTestSkipped('Only test the response queue when running offline tests.');
    return;
  }

  // Queue a response from the mock server.
  $this->stack
    ->addResponse(new Response(200, [], "{\"status\": \"success\"}"));

  // Execute a client call.
  $response = $this->sdkConnector
    ->buildClient(new AutoBasicAuth())
    ->get('/');
  self::assertEquals("200", $response
    ->getStatusCode());
  self::assertEquals('{"status": "success"}', (string) $response
    ->getBody());
}