summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal/FunctionalJavascriptTests/PerformanceTestBase.php
blob: d624e03c00d9509f370d2ef60be68a56931b0e27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

declare(strict_types=1);

namespace Drupal\FunctionalJavascriptTests;

use Drupal\Core\Database\Database;
use Drupal\Tests\PerformanceTestTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Collects performance metrics.
 *
 * @ingroup testing
 */
class PerformanceTestBase extends WebDriverTestBase {
  use PerformanceTestTrait;

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['performance_test'];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->doSetUpTasks();
    \Drupal::service('module_installer')->uninstall(['automated_cron']);
  }

  /**
   * {@inheritdoc}
   */
  protected function prepareEnvironment() {
    parent::prepareEnvironment();
    $db = Database::getConnection();
    $test_file_name = (new \ReflectionClass($this))->getFileName();
    $is_core_test = str_starts_with($test_file_name, DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'core');
    if ($db->databaseType() !== 'mysql' && $is_core_test) {
      $this->markTestSkipped('Drupal core performance tests only run on MySQL');
    }
  }

  /**
   * {@inheritdoc}
   */
  protected function installModulesFromClassProperty(ContainerInterface $container) {
    $this->doInstallModulesFromClassProperty($container);
  }

  /**
   * {@inheritdoc}
   */
  protected function getMinkDriverArgs(): string {
    return $this->doGetMinkDriverArgs();
  }

}