Skip to content

Clear the Mago lint findings in the test suite - #254

Open
simon-mundy wants to merge 5 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-test-lint
Open

simon-mundy wants to merge 5 commits into
php-db:0.6.xfrom
simon-mundy:qa/mago-test-lint

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Problem

lint-baseline.toml carried 92 Mago lint findings in the test suite (test/unit/Sql, test/unit/Adapter, test/unit/ResultSet), including:

  • @ error suppression and an empty catch;
  • snake_case test names;
  • literal arguments passed by position;
  • service-name strings shaped like namespaces;
  • redundant variables, and assignments inside call arguments.

Fix

  • Named arguments: optional literal arguments are passed by name (TableIdentifierFactory::__invoke, str_replace, random_int, var_export, assert).
  • Service names: AbstractAdapterInterfaceFactoryTest uses plain adapter service names (WriteAdapter, ReadAdapter), matching the docs, and its data providers are labelled.
  • No @ suppression:
    • The profiler-on-error test uses PDO::ERRMODE_SILENT. The failing query takes the same false path and still throws InvalidQueryException, without emitting a warning.
    • Sql92Test::quoteValueThrowsWithoutDriver drops assertions that could never run after the first throw, and checks the exception message instead.
  • Tidying: the empty catch, redundant variables and assignments inside arguments are removed.
  • Names:
    • The _get, _isset, _set, _unset and _construct tests get behaviour-describing camelCase names, and lose their @codingStandardsIgnore markers.
    • SelectTest's provider variables are camelCased.
  • Test assets and helpers:
    • isset, empty and elseif are replaced (??=, early returns, array_key_exists()).
    • Predicate\Expression is imported instead of written as a fully qualified name.
    • Quoted identifiers use string interpolation.
  • Removed: a stale commented-out TODO fixture.
  • Baseline: the lint baseline goes from 153 to 71 issues.

What stays the same

  • No src/ changes. No assertion is weakened, and one exception-message assertion is added.
  • The same number of tests.
  • The gateway tests are untouched.
  • 10 findings stay baselined on purpose:
    • no-isset ×6, where the test checks that isset() reaches ArrayAccess or __isset;
    • halstead ×2, on two data providers that are large fixture tables;
    • excessive-parameter-list and no-boolean-flag-parameter on SelectTest::prepareStatement, whose signature has to match the shared provider's row shape.

Verification

  • mago format --check, lint, analyze and guard exit 0 on PHP 8.3, 8.4 and 8.5, with no stale baseline entries.
  • The full PHPUnit suite passes with the same test count as 0.6.x, and no warnings or notices.

Pass optional literal arguments by name and replace namespace-shaped adapter service names with plain names, matching the documented configuration style.
Use PDO::ERRMODE_SILENT so the failing query takes the same error path without emitting a warning, drop the unreachable suppressed assertions in Sql92Test in favour of asserting the exception message, connect directly instead of swallowing exceptions, and drop unused credentials from the SQLite fixture.
…e names

Rename the _get/_isset/_set/_unset/_construct tests, drop their coding standards ignore markers, camel-case the SelectTest data provider variables, and remove a redundant variable and an assignment in an argument.
Replace isset/empty/elseif in test assets and helpers, describe assertions, use a deterministic consecutive return in ResultTest, import the predicate Expression class, interpolate quoted identifiers, and drop a stale commented-out TODO fixture. Remove the lint-baseline entries these commits fixed.
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant