You are here

public function DeveloperAppUITest::testCreateAppWithModifiedCredentialLifetime in Apigee Edge 8

Tests app creation with modified credential lifetime.

Throws

\Behat\Mink\Exception\ResponseTextException

File

tests/src/Functional/DeveloperAppUITest.php, line 252

Class

DeveloperAppUITest
Developer app UI tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testCreateAppWithModifiedCredentialLifetime() {
  $url = Url::fromRoute('apigee_edge.settings.developer_app.credentials');

  // Change credential lifetime to 10 days from 0.
  $this
    ->drupalPostForm($url, [
    'credential_lifetime' => 10,
  ], 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');

  // Create a new developer app and check the credential expiration.
  $name = strtolower($this
    ->randomMachineName());
  $this
    ->postCreateAppForm([
    'name' => $name,
    'displayName[0][value]' => $name,
    "api_products[{$this->products[0]->getName()}]" => $this->products[0]
      ->getName(),
  ]);
  $this
    ->assertSession()
    ->pageTextContains($name);
  $this
    ->clickLink($name);

  // Result depends on how fast the response was.
  $this
    ->assertSession()
    ->pageTextMatches('/1 week (2|3) days hence/');

  // Change credential lifetime to 0 (Never) days from 10.
  $this
    ->drupalPostForm($url, [
    'credential_lifetime' => 0,
  ], 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');

  // Create a new developer app and check the credential expiration.
  $name = strtolower($this
    ->randomMachineName());
  $this
    ->postCreateAppForm([
    'name' => $name,
    'displayName[0][value]' => $name,
    "api_products[{$this->products[0]->getName()}]" => $this->products[0]
      ->getName(),
  ]);
  $this
    ->assertSession()
    ->pageTextContains($name);
  $this
    ->clickLink($name);
  $this
    ->assertSession()
    ->pageTextContains('Never');
}