protected function DeveloperAppAnalyticsTest::visitAnalyticsPage in Apigee Edge 8
Visits the developer app analytics page using the given path.
Parameters
string $path: The path of the analytics page.
bool $appendQueryParameters: A boolean indicating whether the URL query parameters should be appended.
1 call to DeveloperAppAnalyticsTest::visitAnalyticsPage()
- 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 158
Class
- DeveloperAppAnalyticsTest
- Developer app analytics test.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
protected function visitAnalyticsPage(string $path, bool $appendQueryParameters = FALSE) {
$this
->queueAppAnalyticsStackedResponse();
if ($appendQueryParameters) {
$this
->drupalGet($path, $this->queryParameters);
}
else {
$this
->drupalGet($path);
}
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextNotContains('Invalid URL query parameters.');
// End date is before the start date.
$since_in_the_future = new DrupalDateTime();
$since_in_the_future
->add(new \DateInterval('P3D'));
$until = new DrupalDateTime();
$this
->queueAppAnalyticsStackedResponse();
$this
->drupalGet($path, [
'query' => [
'metric' => 'sum(message_count)',
'since' => $since_in_the_future
->getTimestamp(),
'until' => $until
->getTimestamp(),
'environment' => 'prod',
],
]);
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextContains('The end date cannot be before the start date.');
// Start date is in the future.
$until = new DrupalDateTime();
$this
->queueAppAnalyticsStackedResponse();
$this
->drupalGet($path, [
'query' => [
'metric' => 'sum(message_count)',
'since' => $since_in_the_future
->getTimestamp(),
'until' => $until
->add(new \DateInterval('P4D'))
->getTimestamp(),
'environment' => 'prod',
],
]);
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextContains('Start date cannot be in future. The current local time of the Developer Portal:');
// Invalid metric in the URL query.
$this
->queueAppAnalyticsStackedResponse();
$this
->drupalGet($path, [
'query' => [
'metric' => $this
->randomMachineName(),
'since' => $this
->randomMachineName(),
'until' => $this
->randomMachineName(),
'environment' => 'prod',
],
]);
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextContains('Invalid parameter metric in the URL.');
// Invalid timestamp parameters in the URL query.
$this
->queueAppAnalyticsStackedResponse();
$this
->drupalGet($path, [
'query' => [
'metric' => 'min(total_response_time)',
'since' => $this
->randomMachineName(),
'until' => $this
->randomMachineName(),
'environment' => 'prod',
],
]);
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextContains('Invalid URL query parameters.');
// Invalid environment parameters in the URL query.
$this
->queueAppAnalyticsStackedResponse();
$this
->drupalGet($path, [
'query' => [
'metric' => 'min(total_response_time)',
'since' => (new DrupalDateTime())
->getTimestamp(),
'until' => (new DrupalDateTime())
->getTimestamp(),
'environment' => $this
->randomMachineName(),
],
]);
$this
->assertAnalyticsPage();
$this
->assertSession()
->pageTextContains('Invalid parameter environment in the URL.');
}