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

Issue #3463288 by catch: Consolidate test methods in StandardPerformanceTest

parent f1769fae
No related branches found
No related tags found
22 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8736Update the Documention As per the Function uses.,!8513Issue #3453786: DefaultSelection should document why values for target_bundles NULL and [] behave as they do,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #232855 canceled
Pipeline: drupal

#232857

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