Drupal Quality Control & Assurance 4 — Questions and Answers
Question 1: What is the recommended way to test Drupal REST API endpoints for response correctness in automated tests?
- Using ResourceTestBase or extending BrowserTestBase with HTTP client assertions (Correct answer)
- Manually requesting the endpoint via a browser during QA sprints
- Checking the Drupal log for REST module errors after each request
- Validating the OpenAPI schema file without making real requests
Correct answer: Using ResourceTestBase or extending BrowserTestBase with HTTP client assertions
Drupal provides ResourceTestBase specifically for testing REST resources, allowing assertion of HTTP status codes, headers, and response bodies programmatically.
Question 2: When using Behat for Drupal acceptance testing, which extension provides Drupal-specific step definitions like 'Given I am logged in as a user with the role'?
- Drupal Extension (behat/drupal-extension) (Correct answer)
- MinkExtension
- Symfony2Extension
- DrupalDriver
Correct answer: Drupal Extension (behat/drupal-extension)
The behat/drupal-extension package adds Drupal-aware step definitions for users, roles, nodes, and taxonomy terms that standard Behat/Mink steps do not cover.
Question 3: Which metric best indicates that a Drupal module's test suite has adequate coverage for a QA sign-off?
- High code coverage percentage combined with tests for critical user paths (Correct answer)
- The number of test files present in the module directory
- Passing all Drupal core tests without module-specific tests
- Zero PHP notices in the Drupal log during a manual walkthrough
Correct answer: High code coverage percentage combined with tests for critical user paths
Coverage percentage alone is insufficient; meaningful QA sign-off requires both measurable code coverage and explicit tests for the workflows users rely on.
Question 4: What does `drush config:import --diff` do in a QA context?
- Shows the difference between configuration on disk and active configuration before importing (Correct answer)
- Imports only changed configuration files to reduce import time
- Creates a backup diff file before overwriting active config
- Validates config syntax and reports errors without importing
Correct answer: Shows the difference between configuration on disk and active configuration before importing
The `--diff` flag prints a human-readable diff of what will change when config:import runs, allowing QA teams to review changes before applying them.
Question 5: A Drupal site's content editor reports that a WYSIWYG editor toolbar button is missing after a module update. Which type of test would best prevent this regression?
- A functional JavaScript test that checks the editor toolbar renders the expected buttons (Correct answer)
- A unit test for the text format configuration entity
- A kernel test that loads the editor library definitions
- A static analysis check of the CKEditor plugin YAML
Correct answer: A functional JavaScript test that checks the editor toolbar renders the expected buttons
Functional JavaScript tests use a real browser to render CKEditor and can assert that specific toolbar buttons are present in the rendered DOM, catching UI regressions that static tests miss.
Question 6: What is the purpose of the `drupal/coder` Composer package in a Drupal project's QA setup?
- It provides PHP_CodeSniffer ruleset sniffs for Drupal coding standards enforcement (Correct answer)
- It generates Drupal module boilerplate code to coding standards
- It validates Drupal hook implementations for correctness
- It documents API changes between Drupal minor versions
Correct answer: It provides PHP_CodeSniffer ruleset sniffs for Drupal coding standards enforcement
drupal/coder ships the Drupal and DrupalPractice PHP_CodeSniffer sniff sets used to enforce the community's coding standards during linting.
Question 7: When a Drupal hook_update_N function fails midway during `drush updatedb`, what is the safest recovery QA step?
- Restore from the pre-update database backup and investigate the failure before re-running (Correct answer)
- Re-run `drush updatedb` repeatedly until it succeeds
- Manually execute the remaining SQL from the update hook
- Increment the schema version manually in the key_value table
Correct answer: Restore from the pre-update database backup and investigate the failure before re-running
Restoring from backup preserves data integrity and allows root-cause analysis of the failed update before attempting to re-run it in a controlled environment.
What is the recommended way to test Drupal REST API endpoints for response correctness in automated tests?