You are here

protected function DeveloperAppUITestTrait::loadDeveloperApp in Apigee Edge 8

Loads a developer app by name.

Parameters

string $name: Name of the developer app.

\Drupal\apigee_edge\Entity\Developer $developer: The developer the app belongs to.

Return value

\Drupal\apigee_edge\Entity\DeveloperAppInterface|null Loaded developer app or null if not found.

1 call to DeveloperAppUITestTrait::loadDeveloperApp()
DeveloperAppUITestTrait::assertAppCrud in tests/src/Functional/DeveloperAppUITestTrait.php
Goes through a typical CRUD cycle for an app.

File

tests/src/Functional/DeveloperAppUITestTrait.php, line 344

Class

DeveloperAppUITestTrait
Contains re-usable components for developer app UI tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

protected function loadDeveloperApp(string $name, Developer $developer = NULL) : ?DeveloperAppInterface {

  /** @var \Drupal\apigee_edge\Entity\DeveloperApp[] $apps */
  if ($developer) {
    $storage = \Drupal::entityTypeManager()
      ->getStorage('developer_app');
    $results_ids = $storage
      ->getQuery()
      ->condition('developerId', $developer
      ->uuid())
      ->condition('name', $name)
      ->execute();
    return $results_ids ? $storage
      ->load(reset($results_ids)) : NULL;
  }
  else {
    $apps = DeveloperApp::loadMultiple();
    foreach ($apps as $app) {
      if ($app
        ->getName() === $name) {
        return $app;
      }
    }
  }
  return NULL;
}