Drupal Quality Control & Assurance 3 — Questions and Answers
Question 1: In a Drupal CI/CD pipeline, what is the primary purpose of running `composer validate`?
- Verifying that composer.json and composer.lock are consistent and well-formed (Correct answer)
- Checking that all Composer packages pass security audits
- Ensuring all required Drupal modules are installed
- Validating that PHP version constraints are met
Correct answer: Verifying that composer.json and composer.lock are consistent and well-formed
`composer validate` checks that composer.json is syntactically correct and that composer.lock matches the declared dependencies, catching drift before deployment.
Question 2: What Drupal status report warning indicates a potential security risk that QA teams should address immediately?
- Modules with available security updates (Correct answer)
- Modules missing optional configuration
- Themes using deprecated template variables
- Content types without revision tracking
Correct answer: Modules with available security updates
Modules flagged with available security updates in the Status Report represent known vulnerabilities that must be patched to protect the site.
Question 3: Which approach best prevents regressions when refactoring a Drupal custom module's service class?
- Writing unit tests for the service before refactoring, then verifying they still pass after (Correct answer)
- Running `drush cr` and manually checking affected pages
- Incrementing the module's version number in the .info.yml file
- Disabling the module and re-enabling it after refactoring
Correct answer: Writing unit tests for the service before refactoring, then verifying they still pass after
Pre-existing unit tests act as a safety net by immediately revealing if refactoring broke any expected behavior without requiring manual verification.
Question 4: What does the Drupal `DeprecationHelper` (or `@trigger_error` with `E_USER_DEPRECATED`) enable in quality assurance workflows?
- Flagging code paths that will break in future Drupal major versions so they can be fixed proactively (Correct answer)
- Stopping the site from running deprecated functions immediately
- Logging deprecated function calls to the watchdog database table
- Automatically replacing deprecated functions with their successors
Correct answer: Flagging code paths that will break in future Drupal major versions so they can be fixed proactively
Triggering E_USER_DEPRECATED errors allows CI tools like PHPUnit's deprecation tracker to surface deprecated API usage before a major version upgrade breaks the site.
Question 5: In Drupal's automated testing, what is the role of `setUp()` in a test class?
- Initializes the test environment and shared state before each test method runs (Correct answer)
- Defines which modules to install for the entire test suite only once
- Runs after each test to clean up the database
- Registers the test class with the Drupal test discovery system
Correct answer: Initializes the test environment and shared state before each test method runs
`setUp()` is called before every individual test method, providing a fresh and consistent starting state to prevent test interdependence.
Question 6: A QA engineer notices that a Drupal view displays incorrect results after a content type field is renamed. Which QA process would have caught this earliest?
- Functional tests that assert view output after configuration changes (Correct answer)
- A code review of the Views configuration export
- Running `drush config:export` and diffing the output
- Checking the Drupal log for PHP notices
Correct answer: Functional tests that assert view output after configuration changes
Functional tests that load the view and assert expected output against known content would immediately fail when the field rename breaks the view's data source.
Question 7: Which Drupal module is designed to compare configuration between environments to detect unintended config drift?
- Config Split combined with Config Inspector (Correct answer)
- Diff module
- Environment Indicator
- Stage File Proxy
Correct answer: Config Split combined with Config Inspector
Config Inspector (and Config Split for environment-specific splits) allows teams to compare active configuration against stored config exports to detect unintended divergence between environments.
In a Drupal CI/CD pipeline, what is the primary purpose of running `composer validate`?