You are here

public function DeveloperAppUITest::testAppCrudMultiplePruductsRemove in Apigee Edge 8

Creates an app with multiple products and then removes them.

File

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

Class

DeveloperAppUITest
Developer app UI tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testAppCrudMultiplePruductsRemove() {
  $this
    ->submitAdminForm([
    'display_as_select' => TRUE,
  ]);
  $this->products[] = $this
    ->createProduct();
  $this->products[] = $this
    ->createProduct();
  $this
    ->assertAppCrud(function (array $data) : array {
    $data['api_products[]'] = [
      $this->products[0]
        ->getName(),
      $this->products[1]
        ->getName(),
    ];
    return $data;
  }, function () {
    $this
      ->assertSession()
      ->pageTextContains($this->products[0]
      ->label());
    $this
      ->assertSession()
      ->pageTextContains($this->products[1]
      ->label());
    $this
      ->assertSession()
      ->pageTextNotContains($this->products[2]
      ->label());
  }, function (array $data, string $credential_id) : array {
    $data["credential[{$credential_id}][api_products][]"] = [
      $this->products[2]
        ->getName(),
    ];
    return $data;
  }, function () {
    $this
      ->assertSession()
      ->pageTextNotContains($this->products[0]
      ->label());
    $this
      ->assertSession()
      ->pageTextNotContains($this->products[1]
      ->label());
    $this
      ->assertSession()
      ->pageTextContains($this->products[2]
      ->label());
  });
}