You are here

protected function ApigeeEdgeFunctionalTestTrait::createDeveloperApp in Apigee Edge 8

Creates an app for a user.

Parameters

array $data: App data. (developerId gets overridden by $owner's developerId.)

\Drupal\user\UserInterface $owner: Owner of the app.

array $products: List of associated API products.

Return value

\Drupal\apigee_edge\Entity\DeveloperAppInterface The created developer app entity.

Overrides ApigeeMockApiClientHelperTrait::createDeveloperApp

4 calls to ApigeeEdgeFunctionalTestTrait::createDeveloperApp()
DeveloperAppUITest::testCallbackUrlValidationClientSide in tests/src/FunctionalJavascript/DeveloperAppUITest.php
Tests callback url validation on the client-side.
DeveloperAppUITest::testCallbackUrlValidationServerSide in tests/src/Functional/DeveloperAppUITest.php
Tests callback url validation on the server-side.
DeveloperAppUITest::testInvalidEdgeSideCallbackUrl in tests/src/Functional/DeveloperAppUITest.php
Ensures warning message is visible if callback url's value is invalid.
DeveloperAppUITest::testWarningMessagesIfMultipleProductsDisabled in tests/src/Functional/DeveloperAppUITest.php
Ensures warning messages are visible if multiple products/app is disabled.

File

tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php, line 161

Class

ApigeeEdgeFunctionalTestTrait
Provides common functionality for the Apigee Edge test classes.

Namespace

Drupal\Tests\apigee_edge\Traits

Code

protected function createDeveloperApp(array $data, UserInterface $owner, array $products = []) {

  /** @var \Drupal\apigee_edge\Entity\DeveloperAppInterface $app */
  $app = DeveloperApp::create($data);
  $app
    ->setOwner($owner);
  $app
    ->save();
  if (!empty($products)) {

    /** @var \Drupal\apigee_edge\SDKConnectorInterface $connector */
    $connector = \Drupal::service('apigee_edge.sdk_connector');
    $credentials = $app
      ->getCredentials();

    /** @var \Apigee\Edge\Api\Management\Entity\AppCredentialInterface $credential */
    $credential = reset($credentials);

    // We use the non-cached, original SDK controller for this not its
    // Drupal version.
    $dacc = new EdgeDeveloperAppCredentialController($connector
      ->getOrganization(), $app
      ->getDeveloperId(), $app
      ->getName(), $connector
      ->getClient());
    $dacc
      ->addProducts($credential
      ->getConsumerKey(), $products);
  }
  return $app;
}