Skip to content

test: fix Session tests execution in random order#10370

Open
gr8man wants to merge 3 commits into
codeigniter4:developfrom
gr8man:fix-session-tests-random-order
Open

test: fix Session tests execution in random order#10370
gr8man wants to merge 3 commits into
codeigniter4:developfrom
gr8man:fix-session-tests-random-order

Conversation

@gr8man

@gr8man gr8man commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description
Ref: #9968

This PR fixes an issue that caused tests in the Session component to randomly fail with database errors (e.g., SQLite3Exception: table 'db_type_test' already exists) when executed with --order-by=random.

The root cause was traced to AbstractHandlerTestCase::setUp(), where parent::setUp() was being invoked before evaluating if the test should be skipped due to unsupported database drivers. Since parent::setUp() runs DatabaseTestTrait's migrations and initializes the test database (SQLite by default), skipping the test right after it meant that tearDown() was never executed by PHPUnit. As a result, the database was left dirty with leftover tables, which randomly broke subsequent database tests.

Moving markTestSkipped() above parent::setUp() cleanly skips the unsupported tests without initializing the database, ensuring 100% stability when running the suite in random order.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@github-actions github-actions Bot added the testing Pull requests that changes tests only label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Pull requests that changes tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant