Problem/Motivation
The Country module currently has minimal test coverage with only 2 functional tests in a single test file. This limited coverage makes it difficult to:
- Detect regressions when making changes
- Verify that all components work correctly
- Maintain code quality and stability
- Ensure compatibility with new Drupal core versions
The module's core functionality including field types, formatters, widgets, Views integration, and the CountryFieldManager service lack automated test coverage.
Proposed resolution
Add comprehensive PHPUnit test coverage for the Country module's core components:
- CountryFieldManager service: Test country list retrieval and selectable countries with restrictions
- CountryItem field type: Test isEmpty(), validation constraints, and options providers
- Field formatters: Test CountryDefaultFormatter and CountryCodeFormatter output
- Field widgets: Test CountryDefaultWidget and CountryAutocompleteWidget rendering and validation
- Views integration: Test filter and sort plugins
- Autocomplete controller: Test search functionality and JSON responses
Use kernel tests for services and plugins (fast execution), and functional tests only where browser interaction is required.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | PassedTests.png | 280.41 KB | immoreel |
Issue fork country-3564737
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
batigolixComment #4
immoreel commentedWorks as advertised, all tests pass, see https://git.drupalcode.org/project/country/-/pipelines/696826

Comment #5
immoreel commentedComment #6
batigolix