You are here

public function TestFrameworkKernelTest::testStackedMockResponse in Apigee Edge 8

Tests that a response is fetched from the stacked mocks.

File

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

Class

TestFrameworkKernelTest
Tests the testing framework for testing offline.

Namespace

Drupal\Tests\apigee_edge\Kernel

Code

public function testStackedMockResponse() {
  if ($this->integration_enabled) {
    $this
      ->markTestSkipped('Integration enabled, skipping test.');
  }
  $test_user = [
    'mail' => $this
      ->randomMachineName() . '@example.com',
    'name' => $this
      ->randomMachineName(),
    'first_name' => $this
      ->getRandomGenerator()
      ->word(16),
    'last_name' => $this
      ->getRandomGenerator()
      ->word(16),
  ];
  $account = $this->entityTypeManager
    ->getStorage('user')
    ->create($test_user);
  $this
    ->assertEquals($test_user['mail'], $account->mail->value);
  $this
    ->queueDeveloperResponse($account);
  $developerStorage = $this->entityTypeManager
    ->getStorage('developer');
  $developerStorage
    ->resetCache([
    $test_user['mail'],
  ]);

  /** @var \Drupal\apigee_edge\Entity\Developer $developer */
  $developer = $developerStorage
    ->load($test_user['mail']);
  $this
    ->assertEqual($developer
    ->getEmail(), $test_user['mail']);

  // Attribute is set by mock twig template.
  $this
    ->assertEqual($developer
    ->getAttributeValue('IS_MOCK_CLIENT'), 1);
}