You are here

public function DeveloperAppUITest::testCreateAndDeleteApp in Apigee Edge 8

Creates and deletes an app.

File

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

Class

DeveloperAppUITest
Developer app UI tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testCreateAndDeleteApp() {
  $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($name);
  $this
    ->assertSession()
    ->pageTextContains($this->products[0]
    ->label());
  $this
    ->clickLink('Delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->assertSession()
    ->pageTextContains('The name does not match the app you are attempting to delete.');
  $this
    ->submitForm([
    'verification_code' => $name,
  ], 'Delete');
  $this
    ->assertSession()
    ->pageTextContains("The {$name} app has been deleted.");
  $apps = array_filter($this
    ->getApps(), function (DeveloperApp $app) use ($name) : bool {
    return $app
      ->getName() === $name;
  });
  $this
    ->assertEquals([], $apps, 'App is deleted');
  $this
    ->drupalGet("user/{$this->account->id()}/apps");
  $this
    ->assertSession()
    ->pageTextNotContains($name);
}