You are here

protected function DeveloperAppAnalyticsTest::exportAnalyticsTest in Apigee Edge 8

Tests the export analytics route.

1 call to DeveloperAppAnalyticsTest::exportAnalyticsTest()
DeveloperAppAnalyticsTest::testAnalytics in tests/src/Functional/DeveloperAppAnalyticsTest.php
Tests the analytics page with the logged in developer app owner.

File

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

Class

DeveloperAppAnalyticsTest
Developer app analytics test.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

protected function exportAnalyticsTest() {
  $this
    ->drupalLogin($this->rootUser);
  $data_id = Crypt::randomBytesBase64();
  $this
    ->drupalGet(Url::fromRoute('apigee_edge.export_analytics.csv', [
    'data_id' => $data_id,
  ]));
  $this
    ->assertEquals(403, $this
    ->getSession()
    ->getStatusCode());

  // Without CSRF token.
  $store = $this->container
    ->get('tempstore.private')
    ->get('apigee_edge.analytics');

  /** @var \Drupal\Core\TempStore\PrivateTempStore $store */
  $store
    ->set($data_id = Crypt::randomBytesBase64(), []);
  $this
    ->drupalGet(Url::fromRoute('apigee_edge.export_analytics.csv', [
    'data_id' => $data_id,
  ]));
  $this
    ->assertEquals(403, $this
    ->getSession()
    ->getStatusCode());
}