You are here

protected function DeveloperAppAnalyticsTest::setUp in Apigee Edge 8

Overrides ApigeeEdgeFunctionalTestBase::setUp

File

tests/src/Functional/DeveloperAppAnalyticsTest.php, line 73

Class

DeveloperAppAnalyticsTest
Developer app analytics test.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->account = $this
    ->createAccount([
    'analytics own developer_app',
    'analytics any developer_app',
  ]);
  $this
    ->queueDeveloperResponse($this->account, 200);
  $this->developer = Developer::load($this->account
    ->getEmail());
  $this->developerApp = DeveloperApp::create([
    'name' => $this
      ->randomMachineName(),
    'displayName' => $this
      ->randomMachineName(),
    'status' => App::STATUS_APPROVED,
    'developerId' => $this->developer
      ->getDeveloperId(),
  ]);
  $this->developerApp
    ->setOwner($this->account);
  $this
    ->queueDeveloperAppResponse($this->developerApp, 201);
  $this->developerApp
    ->save();

  // Build the URL query string.
  $since = new DrupalDateTime();
  $until = new DrupalDateTime();
  $this->queryParameters = [
    'query' => [
      'metric' => 'min(total_response_time)',
      'since' => $since
        ->sub(new \DateInterval('P3D'))
        ->getTimestamp(),
      'until' => $until
        ->sub(new \DateInterval('P2D'))
        ->getTimestamp(),
      'environment' => 'prod',
    ],
  ];
}