function PerformanceTestTrait::assertQueriesByName
Same name and namespace in other branches
- main core/tests/Drupal/Tests/PerformanceTestTrait.php \Drupal\Tests\PerformanceTestTrait::assertQueriesByName()
Asserts queries against the stored expectations.
Expected queries are stored in the folder named TestClassNameAssertions in the same directory.
Parameters
string $name: A identifier for the expected queries. Must be unique for the given test.
array $queries: List of executed queries.
5 calls to PerformanceTestTrait::assertQueriesByName()
- JsonApiPerformanceTest::testGetIndividual in core/
modules/ jsonapi/ tests/ src/ FunctionalJavascript/ JsonApiPerformanceTest.php - Tests performance of the navigation toolbar.
- OpenTelemetryPerformanceTest::doTestFrontPageAuthenticatedWarmCache in core/
profiles/ demo_umami/ tests/ src/ FunctionalJavascript/ OpenTelemetryPerformanceTest.php - Logs front page tracing data with an authenticated user and warm cache.
- OpenTelemetryPerformanceTest::testNodePageWarmCache in core/
profiles/ demo_umami/ tests/ src/ FunctionalJavascript/ OpenTelemetryPerformanceTest.php - Log node/1 tracing data with a warm cache.
- StandardPerformanceTest::testAdmin in core/
profiles/ standard/ tests/ src/ FunctionalJavascript/ StandardPerformanceTest.php - Tests performance of a logged-in admin user with the navigation toolbar.
- StandardPerformanceTest::testAnonymous in core/
profiles/ standard/ tests/ src/ FunctionalJavascript/ StandardPerformanceTest.php - Tests performance for anonymous users.
File
-
core/
tests/ Drupal/ Tests/ PerformanceTestTrait.php, line 748
Class
- PerformanceTestTrait
- Provides various methods to aid in collecting performance data during tests.
Namespace
Drupal\TestsCode
protected function assertQueriesByName(string $name, array $queries) : void {
$filename = $this->getExpectationsFilename($name, 'sql');
$content = file_exists($filename) ? trim(file_get_contents($filename)) : '';
if (empty($content) || $this->shouldUpdate()) {
file_put_contents($filename, implode("\n", $queries) . "\n");
}
else {
$this->assertEquals(explode("\n", $content), $queries);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.