Drupal Quality Control & Assurance 2 — Questions and Answers
Question 1: Which Drupal module provides a centralized dashboard for running automated tests from the admin UI?
- Simpletest UI (Correct answer)
- Test Runner
- PHPUnit Dashboard
- QA Dashboard
Correct answer: Simpletest UI
Simpletest UI (now largely replaced by PHPUnit) provided an admin interface for running tests directly from the Drupal backend.
Question 2: What does the `--filter` flag do when running Drupal PHPUnit tests via the CLI?
- Runs only tests matching a given name or pattern (Correct answer)
- Filters out deprecated test methods
- Excludes slow tests from the suite
- Filters log output to warnings only
Correct answer: Runs only tests matching a given name or pattern
The `--filter` flag narrows the test run to only those test cases or methods whose names match the provided string or regex pattern.
Question 3: In Drupal's testing architecture, what is a 'functional JavaScript test' (FunctionalJavascriptTestCase) used for?
- Testing behaviors that require a real browser with JS execution (Correct answer)
- Unit testing JavaScript utility functions
- Linting JavaScript files for syntax errors
- Validating JS module dependencies
Correct answer: Testing behaviors that require a real browser with JS execution
FunctionalJavascriptTestCase uses WebDriver (via Chromedriver) to run a real browser, enabling testing of AJAX, dynamic content, and other JS-driven behaviors.
Question 4: Which coding standard tool is most commonly used for Drupal PHP code quality checks in CI pipelines?
- PHP_CodeSniffer with Drupal standards (Correct answer)
- PHPStan alone
- Psalm
- SonarQube PHP plugin
Correct answer: PHP_CodeSniffer with Drupal standards
PHP_CodeSniffer configured with the Drupal and DrupalPractice sniff sets is the standard linting tool used by the Drupal community and enforced in CI.
Question 5: What is the purpose of the `drupal_flush_all_caches()` call commonly used in test teardown?
- Ensures a clean cache state so subsequent tests are not affected by cached data (Correct answer)
- Permanently deletes all caches from production
- Rebuilds the Drupal container from scratch
- Clears only the render cache
Correct answer: Ensures a clean cache state so subsequent tests are not affected by cached data
Flushing all caches in teardown prevents stale cached data from leaking into subsequent test runs and causing false positives or negatives.
Question 6: When writing a Drupal KernelTest, which of the following is TRUE compared to a UnitTest?
- KernelTest bootstraps part of the Drupal kernel and can use the service container (Correct answer)
- KernelTest is faster because it skips all service initialization
- KernelTest requires a full database and browser
- KernelTest only works with Drupal core modules
Correct answer: KernelTest bootstraps part of the Drupal kernel and can use the service container
KernelTestBase bootstraps a minimal Drupal kernel with the service container available, allowing interaction with services and the database without a full HTTP request cycle.
Question 7: Which Drush command can be used to check whether a Drupal site has any pending database updates that need to be run?
- drush updatedb-status (Correct answer)
- drush status-check
- drush db-pending
- drush updb --check
Correct answer: drush updatedb-status
`drush updatedb-status` (alias `updb-status`) lists all pending hook_update_N implementations without actually running them.
Which Drupal module provides a centralized dashboard for running automated tests from the admin UI?