Skip to content

Close the data-provider gap in the largest test suites #140

Description

@AlexSkrypnyk

Summary

AGENTS.md states "Use data providers as much as possible" under Unit Tests. The convergence pass behind #138 measured how far the suite follows that, and the gap is concentrated in the biggest files. Split out as a follow-up so it does not obscure the convention work in that pull request.

The suite has 147 data providers overall and they are 100% compliant with the naming rule: every one is dataProvider-prefixed and placed after the test it feeds. The gap is adoption, not naming.

Details

Where the gap is

  • tests/phpunit/Unit/Render/PanelControllerTest.php - 80 tests, 1602 lines, zero data providers. It repeats the same Enter/Enter drill-then-edit key sequence in roughly 25 test bodies. Explicit provider-shaped twins: the modal Cancel-button versus Escape pair at lines 805-821 and 823-839, the fullscreen too-small guard variants at 992-1015, and the textarea editor-hint shown/hidden pair at 681-701.
  • tests/phpunit/Unit/Builder/FormTest.php - 52 tests, only 3 providers, with 20 structurally identical one-off ...Throws methods of about 8 lines each. These sit directly beside dataProviderLayoutMismatchThrows in the same file, which already demonstrates the provider-of-closures alternative. This is the clearest single win.
  • tests/phpunit/Unit/Schema/AgentHelpTest.php - 23 tests, 0 providers.
  • tests/phpunit/Unit/Resolver/InputResolverTest.php - 21 tests, 0 providers. The six env-alias tests and seven coercion tests are provider-shaped.
  • tests/phpunit/Unit/Schema/SchemaGeneratorTest.php - 16 tests, 0 providers. Its four closure-default tests duplicate scenarios already covered verbatim in DefaultResolverTest.
  • tests/phpunit/Unit/Widget/WidgetFactoryTest.php - testCreatesByType is 17 sequential assertInstanceOf lines in a single body.

Suggested order of work, smallest and safest first

  1. FormTest's 20 ...Throws methods, following the provider-of-closures pattern already present in that file.
  2. PanelControllerTest's explicit twins listed above.
  3. The Schema and Resolver suites.

Note

This is a test-only refactor with no production code change, so the existing suite is its own safety net: coverage should stay equivalent while the number of test methods drops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions