Skip to content

Fix $namespace = null in pre-existing test classes to prevent vendor migrations running against test DB #4819

Open

Description

@objecttothis

Problem

Several test classes set protected $namespace = null, which causes CI4's migration runner to discover and execute migrations from all registered namespaces — including vendor packages like CodeIgniter\Queue. Those vendor migrations create tables without the app's extra columns (e.g. batch_id on queue_jobs), causing failures like:

CodeIgniter\Database\Exceptions\DatabaseException: Unknown column 'batch_id' in 'field list'

Only app-namespace migrations should ever run against the test database.

AGENTS.md fix needed

The bootstrap example in the Testing section currently shows:

protected $namespace = null;

This must be corrected to:

protected $namespace = 'App';

And an explicit rule should be added stating: always set $namespace = 'App' — never null.

Test files to fix

The following pre-existing test files set $namespace = null and need it changed to 'App':

  • tests/Models/AppconfigTest.php
  • tests/Helpers/migration_helperTest.php
  • tests/Models/ItemBulkUpdateTest.php
  • tests/Models/ItemTaxesMultipleTest.php
  • tests/Models/ItemSearchTest.php
  • tests/Controllers/TaxesControllerTest.php
  • tests/Models/ItemTest.php
  • tests/Controllers/NoAccessControllerTest.php
  • tests/Controllers/OfficeControllerTest.php
  • tests/Controllers/ReceivingsControllerTest.php
  • tests/Models/Stock_locationTest.php
  • tests/Models/TaxTest.php
  • tests/Config/FiltersTest.php

Each change is a one-line fix per file. They should be batched in a single PR.

Activity

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

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