PerformanceTest.php

Same filename and directory in other branches
  1. 10 core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php

Namespace

Drupal\Tests\demo_umami\FunctionalJavascript

File

core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\demo_umami\FunctionalJavascript;

use Drupal\FunctionalJavascriptTests\PerformanceTestBase;

/**
 * Tests demo_umami profile performance.
 *
 * @group Performance
 */
class PerformanceTest extends PerformanceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $profile = 'demo_umami';
    
    /**
     * Just load the front page.
     */
    public function testPagesAnonymous() : void {
        $performance_data = $this->collectPerformanceData(function () {
            $this->drupalGet('<front>');
        });
        $this->assertSession()
            ->pageTextContains('Umami');
        $this->assertSame(2, $performance_data->getStylesheetCount());
        $this->assertSame(1, $performance_data->getScriptCount());
        $performance_data = $this->collectPerformanceData(function () {
            $this->drupalGet('node/1');
        });
        $this->assertSame(2, $performance_data->getStylesheetCount());
        $this->assertSame(1, $performance_data->getScriptCount());
    }
    
    /**
     * Load the front page as a user with access to Toolbar.
     */
    public function testFrontPagePerformance() : void {
        $admin_user = $this->drupalCreateUser([
            'access toolbar',
        ]);
        $this->drupalLogin($admin_user);
        $performance_data = $this->collectPerformanceData(function () {
            $this->drupalGet('<front>');
        });
        $this->assertSession()
            ->pageTextContains('Umami');
        $this->assertSame(2, $performance_data->getStylesheetCount());
        $this->assertSame(2, $performance_data->getScriptCount());
    }

}

Classes

Title Deprecated Summary
PerformanceTest Tests demo_umami profile performance.

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