Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>CodeIgniter 4 Test GeneratorNew to Visual Studio Code? Get it now.
CodeIgniter 4 Test Generator

CodeIgniter 4 Test Generator

Maulana Yusuf Ahmadi

|
21 installs
| (0) | Free
Generate PHPUnit tests for CodeIgniter 4 controllers
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CodeIgniter 4 Test Generator

A Visual Studio Code extension for generating PHPUnit tests for CodeIgniter 4 applications. This extension helps you quickly create test files for your controllers and models, following best practices for unit testing in CodeIgniter 4.

Features

Test Generation

  • Generate tests for controllers
  • Automatic method detection and test generation
  • Support for CodeIgniter 4's namespace system
  • Integration with CodeIgniter 4's testing framework
  • Tests are generated in the tests/unit directory

Testing Framework Integration

  • One-click installation of PHPUnit
  • Database testing support

UI Features

  • Easy-to-use interface for test generation
  • Configuration settings for test directory and AI model

Installation

  1. Install the extension from the VS Code marketplace
  2. Open your CodeIgniter 4 project in VS Code
  3. Install PHPUnit using the command palette (Ctrl+Shift+P):
    • Select "Install PHPUnit"
    • Wait for the installation to complete

Usage

Generating Tests

  1. Open the command palette (Ctrl+Shift+P)
  2. Choose one of the following options:
    • "Generate Test" - Generate a test for the current file
    • "Generate Test with AI" - Generate a test using AI assistance
    • "Generate Test Suite" - Generate tests for multiple files
    • "Open Test Generator UI" - Open the interactive test generator

Running Tests

  1. Open the command palette (Ctrl+Shift+P)
  2. Select "Run Tests"
  3. View the test results in the terminal

Configuration

  1. Open the command palette (Ctrl+Shift+P)
  2. Select "Configure Path Settings"
  3. Adjust the following settings:
    • Test Directory: Where test files will be generated (default: tests/unit)
    • AI Model: Choose between different AI models for test generation

Test Templates

Controller Tests

namespace Tests\Unit\Controllers;

use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use CodeIgniter\Test\FeatureTestTrait;
use App\Controllers\ExampleController;

class ExampleControllerTest extends CIUnitTestCase
{
    use DatabaseTestTrait;
    use FeatureTestTrait;

    protected function setUp(): void
    {
        parent::setUp();
        $this->resetServices();
    }

    protected function tearDown(): void
    {
        parent::tearDown();
    }

    public function test_index()
    {
        $result = $this->withSession([
            'user_id' => 1,
            'email' => 'test@example.com'
        ])->get('/example/index');

        $this->assertTrue($result->isOK());
    }
}

Requirements

  • Visual Studio Code 1.60.0 or higher
  • CodeIgniter 4.x
  • PHP 7.4 or higher
  • Composer (for dependency management)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

  • CodeIgniter team for the amazing framework
  • PHPUnit team for the testing framework
  • VS Code team for the extensible editor
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft