Skip to content
Snippets Groups Projects
Verified Commit 816ac01b authored by Dave Long's avatar Dave Long
Browse files

Issue #3463288 by catch: Consolidate test methods in StandardPerformanceTest

(cherry picked from commit 24b7c3ff)
parent 7c9adb2d
No related branches found
No related tags found
11 merge requests!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8949Backport .gitlabci.yml changes.,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #232746 passed with warnings
Pipeline: drupal

#232795

    Pipeline: drupal

    #232793

      Pipeline: drupal

      #232777

        +6
        ...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
        use Drupal\FunctionalJavascriptTests\PerformanceTestBase; use Drupal\FunctionalJavascriptTests\PerformanceTestBase;
        use Drupal\Tests\PerformanceData; use Drupal\Tests\PerformanceData;
        use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
        use Drupal\user\UserInterface;
        /** /**
        * Tests the performance of basic functionality in the standard profile. * Tests the performance of basic functionality in the standard profile.
        ...@@ -29,6 +30,11 @@ class StandardPerformanceTest extends PerformanceTestBase { ...@@ -29,6 +30,11 @@ class StandardPerformanceTest extends PerformanceTestBase {
        */ */
        protected $profile = 'standard'; protected $profile = 'standard';
        /**
        * The user account created during testing.
        */
        protected ?UserInterface $user = NULL;
        /** /**
        * {@inheritdoc} * {@inheritdoc}
        */ */
        ...@@ -43,10 +49,19 @@ protected function setUp(): void { ...@@ -43,10 +49,19 @@ protected function setUp(): void {
        user_role_grant_permissions('anonymous', ['access user profiles']); user_role_grant_permissions('anonymous', ['access user profiles']);
        } }
        /**
        * Tests performance of the standard profile.
        */
        public function testStandardPerformance(): void {
        $this->testAnonymous();
        $this->testLogin();
        $this->testLoginBlock();
        }
        /** /**
        * Tests performance for anonymous users. * Tests performance for anonymous users.
        */ */
        public function testAnonymous(): void { protected function testAnonymous(): void {
        // Request the front page, then immediately clear all object caches, so that // Request the front page, then immediately clear all object caches, so that
        // aggregates and image styles are created on disk but otherwise caches are // aggregates and image styles are created on disk but otherwise caches are
        // empty. // empty.
        ...@@ -146,9 +161,9 @@ public function testAnonymous(): void { ...@@ -146,9 +161,9 @@ public function testAnonymous(): void {
        $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
        // Test user profile page. // Test user profile page.
        $user = $this->drupalCreateUser(); $this->user = $this->drupalCreateUser();
        $performance_data = $this->collectPerformanceData(function () use ($user) { $performance_data = $this->collectPerformanceData(function () {
        $this->drupalGet('user/' . $user->id()); $this->drupalGet('user/' . $this->user->id());
        }, 'standardUserPage'); }, 'standardUserPage');
        $this->assertNoJavaScript($performance_data); $this->assertNoJavaScript($performance_data);
        $this->assertSame(1, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getStylesheetCount());
        ...@@ -182,23 +197,22 @@ public function testAnonymous(): void { ...@@ -182,23 +197,22 @@ public function testAnonymous(): void {
        /** /**
        * Tests the performance of logging in. * Tests the performance of logging in.
        */ */
        public function testLogin(): void { protected function testLogin(): void {
        // Create a user and log them in to warm all caches. Manually submit the // 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 // 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 // this twice so that any caches which take two requests to warm are also
        // covered. // covered.
        $account = $this->drupalCreateUser();
        foreach (range(0, 1) as $index) { foreach (range(0, 1) as $index) {
        $this->drupalGet('node'); $this->drupalGet('node');
        $this->drupalGet('user/login'); $this->drupalGet('user/login');
        $this->submitLoginForm($account); $this->submitLoginForm($this->user);
        $this->drupalLogout(); $this->drupalLogout();
        } }
        $this->drupalGet('node'); $this->drupalGet('node');
        $this->drupalGet('user/login'); $this->drupalGet('user/login');
        $performance_data = $this->collectPerformanceData(function () use ($account) { $performance_data = $this->collectPerformanceData(function () {
        $this->submitLoginForm($account); $this->submitLoginForm($this->user);
        }, 'standardLogin'); }, 'standardLogin');
        $expected_queries = [ $expected_queries = [
        ...@@ -228,30 +242,29 @@ public function testLogin(): void { ...@@ -228,30 +242,29 @@ public function testLogin(): void {
        $this->assertSame(1, $performance_data->getCacheTagChecksumCount()); $this->assertSame(1, $performance_data->getCacheTagChecksumCount());
        $this->assertSame(23, $performance_data->getCacheTagIsValidCount()); $this->assertSame(23, $performance_data->getCacheTagIsValidCount());
        $this->assertSame(0, $performance_data->getCacheTagInvalidationCount()); $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
        $this->drupalLogout();
        } }
        /** /**
        * Tests the performance of logging in via the user login block. * Tests the performance of logging in via the user login block.
        */ */
        public function testLoginBlock(): void { protected function testLoginBlock(): void {
        $this->drupalPlaceBlock('user_login_block'); $this->drupalPlaceBlock('user_login_block');
        // Create a user and log them in to warm all caches. Manually submit the // Log the user in in to warm all caches. Manually submit the form so that
        // form so that we repeat the same steps when recording performance data. Do // we repeat the same steps when recording performance data. Do this twice
        // this twice so that any caches which take two requests to warm are also // so that any caches which take two requests to warm are also covered.
        // covered.
        $account = $this->drupalCreateUser();
        foreach (range(0, 1) as $index) { foreach (range(0, 1) as $index) {
        $this->drupalGet('node'); $this->drupalGet('node');
        $this->assertSession()->responseContains('Password'); $this->assertSession()->responseContains('Password');
        $this->submitLoginForm($account); $this->submitLoginForm($this->user);
        $this->drupalLogout(); $this->drupalLogout();
        } }
        $this->drupalGet('node'); $this->drupalGet('node');
        $this->assertSession()->responseContains('Password'); $this->assertSession()->responseContains('Password');
        $performance_data = $this->collectPerformanceData(function () use ($account) { $performance_data = $this->collectPerformanceData(function () {
        $this->submitLoginForm($account); $this->submitLoginForm($this->user);
        }, 'standardBlockLogin'); }, 'standardBlockLogin');
        $expected_queries = [ $expected_queries = [
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment