function MultipleRequestsPerformanceTest::doTestLogin

Tests the performance of logging in.

File

core/profiles/demo_umami/tests/src/FunctionalJavascript/MultipleRequestsPerformanceTest.php, line 122

Class

MultipleRequestsPerformanceTest
Tests demo_umami profile performance.

Namespace

Drupal\Tests\demo_umami\FunctionalJavascript

Code

protected function doTestLogin() : void {
  $this->drupalLogout();
  $user = $this->createUser();
  // Create a user and log them in to warm all caches. Manually submit the
  // form so that we repeat the same steps when recording performance data. Do
  // this twice so that any caches which take two requests to warm are also
  // covered.
  for ($i = 0; $i < 2; $i++) {
    $this->drupalGet('user/login');
    $this->submitLoginForm($user);
    $this->drupalLogout();
  }
  $this->drupalGet('user/login');
  $performance_data = $this->collectPerformanceData(function () use ($user) {
    $this->submitLoginForm($user);
  }, 'umamiLogin');
  $this->assertQueriesByName('umamiLogin', $performance_data->getQueries());
  $this->assertMetricsByName('umamiLogin', $performance_data);
  $this->drupalLogout();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.