What is CodeIgniter 4's testing support?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
CodeIgniter 4 has a solid built-in testing infrastructure built on PHPUnit. The CIUnitTestCase base class provides CI-specific helpers. Feature tests simulate HTTP requests without starting a real server: $result = $this->call("get", "/users") — test the response: $result->assertStatus(200)->assertSee("Alice")->assertHeaderEmitted("Content-Type", "application/json"). Database tests: use the DatabaseTestTrait with $seed = "UserSeeder" to populate data. Check database state: $this->seeInDatabase("users", ["email" => "alice@example.com"]). Session tests: $result->assertSessionHas("user_id"). Mock services: Services::injectMock("email", $mockEmail). Run tests: vendor/bin/phpunit or php spark test. Test files go in tests/.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real CodeIgniter project.