Skip to content

test: raise line coverage - #304

Merged
roxblnfk merged 11 commits into
2.xfrom
test/coverage-100
Nov 21, 2026
Merged

roxblnfk merged 11 commits into
2.xfrom
test/coverage-100

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What was changed

  • Tests for the code no suite reached yet: failed and refused transaction calls (including a failed reconnect on begin), where-argument checks, full joins, query state given to constructors, redeclared schema elements, MySQL table engines and bit/zero-timestamp defaults, Postgres native enums read in bulk, primary types on existing Postgres columns, abandoned Postgres cursors, SQL Server enum/decimal/default changes of existing columns, and the handlers' rejection of foreign columns and tables.
  • Line coverage over all five suites, measured locally with Xdebug: 93.4% → 95.4%. Unit + SQLite alone: 62.0% → 63.3%. Codecov over the five flags of 5a27dc6: 92.50% → 94.54% (395 → 287 misses).

Why?

Coverage goes up before the mutation work resumes.

Review notes

  • Most of the remaining Codecov misses are not pcov. When a suite never loads a file, Testo (testo/codecov 0.2.5, ExecutableLines) guesses its executable lines from tokens. The guess counts lines PHP never puts an opcode on: string literals concatenated into a constant, the format line of a sprintf() (PHP 8.4+ compiles it to a rope), the if ( opener of a multi-line condition, the signature of a promoted constructor, and argument lines that hold only a variable. Codecov merges flags line by line, so a line one suite guesses and the suite that runs the file never reports stays missed. On 2.x that is 213 of the 395 misses, e.g. the SQL strings in SQLServerHandler::fetchBulk*(), SQLServerTable::fetchIndexes() and SQLServerCompiler. A line drops out only when all five suites load the file, which tests cannot do for driver-specific classes. The fix belongs in Testo's estimator. This PR closes the one generic case, UnexpectedOperatorException: the unit suite now loads it.
  • Bug: PostgresTable::getSequence() always returns null. fetchPrimaryKeys() checks \is_array($this->primarySequence) on a ?string property, so lines 255-259 never run.
  • Bug: foreign-key handling compares a string to an array. MySQLHandler::alterColumn(), SQLServerHandler::alterColumn() and the dropped-column loop in AbstractTable compare $column->getName() === $foreign->getColumns(), which is never true. The foreign-key backup and restore around a column change never runs, and a dropped column's foreign keys are never forgotten. Changing the nullability of a referencing column still works on all four servers.
  • Bug: where('x', 'between', $a, <subquery or fragment>) throws a TypeError. Compiler::condition() binds the second bound as a parameter without checking its type. The CompilerCache lines 355-366 only run on the way to this crash.
  • Minor bug: ActiveQuery::withDriver() without a prefix. It stores a null prefix, and a later sqlStatement() fails because the compiler expects a string.
  • Unreachable:
    • Fallbacks that only run when createInstance() gets null constraint or enum maps, which no caller in the package passes: PostgresColumn 701-708, 736-738; SQLServerColumn 197-202, 426-431.
    • Branches cut off by an earlier guard: PostgresHandler 122 (the search schemas are never empty), SQLServerHandler 259 (empty id lists are filtered out first), SQLServerTable 50 (an existing table always has columns), PostgresColumn 801-802 (Postgres always prints bit defaults with a :: cast, which the branch before this one catches).
    • The Compiler, SQLiteCompiler and CompilerCache branches for insert values that are not Parameters, and for an upsert without a conflict target: the builders never produce either. Driver 182-184 (clearCache() cannot throw), 420 (the public identifier() method answers the call first) and 615-618. Handler 265, AbstractColumn 745, and SQLiteColumn 261 (isEnum() is always false).
    • ColumnAttributesTrait::isAttribute() has no caller.
    • polyfill.php and functions_polyfill.php only define their functions on PHP below 8.1, and the package requires 8.2.
  • Not reachable on the CI servers: MySQLTable 98 (MariaDB only), MySQLColumn 254 and 265 (MySQL always reports collations with a charset prefix and lowercase types), and SQLServerDriver 254 (SQL Server older than 2012).

Checklist

  • Tested
    • Every suite run locally against SQLite, MySQL, Postgres and SQL Server from the cycle/testing compose file
    • Unit tests added

…mpiler's rejected fragments

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…iven to query constructors

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
… expression

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…a name

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…d a driver outside the Driver hierarchy

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…arset changes and a dropped link

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…sting columns, abandoned cursors and the $user schema

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…columns

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…ect and dropping an enum column

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested a review from a team November 20, 2026 20:39
@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.56%. Comparing base (45fb043) to head (edc8d4e).

Additional details and impacted files
@@            Coverage Diff             @@
##              2.x     #304      +/-   ##
==========================================
+ Coverage   92.51%   94.56%   +2.04%     
==========================================
  Files         143      143              
  Lines        5263     5260       -3     
==========================================
+ Hits         4869     4974     +105     
+ Misses        394      286     -108     
Flag Coverage Δ
mysql 52.53% <ø> (+0.25%) ⬆️
postgres 59.42% <ø> (+0.48%) ⬆️
sqlite 50.46% <ø> (+0.09%) ⬆️
sqlserver 53.62% <ø> (+0.25%) ⬆️
unit 56.06% <ø> (+1.68%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roxblnfk
roxblnfk merged commit a51fea3 into 2.x Nov 21, 2026
25 checks passed
@roxblnfk
roxblnfk deleted the test/coverage-100 branch November 21, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant