Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Symfony Test Manager Laravel Package

cmoclyn/symfony-test-manager

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require cmoclyn/symfony-test-manager
    

    Publish the config (if needed):

    php artisan vendor:publish --provider="Cmoclyn\TestManager\TestManagerServiceProvider"
    
  2. First Use Case Register a test suite in config/test-manager.php:

    'suites' => [
        'unit' => [
            'path' => base_path('tests/Unit'),
            'bootstrap' => base_path('tests/Unit/bootstrap.php'),
        ],
        'feature' => [
            'path' => base_path('tests/Feature'),
            'bootstrap' => base_path('tests/Feature/bootstrap.php'),
        ],
    ],
    

    Run tests via Artisan:

    php artisan test:run unit
    
  3. Key Files to Review

    • config/test-manager.php (configuration)
    • app/Providers/TestManagerServiceProvider.php (customization)
    • routes/test-manager.php (if exposing API endpoints)

Implementation Patterns

Workflow Integration

  1. Test Suite Registration Dynamically register suites in TestManagerServiceProvider:

    public function register()
    {
        $this->app->singleton('test-manager', function ($app) {
            return new TestManager([
                'unit' => base_path('tests/Unit'),
                'feature' => base_path('tests/Feature'),
            ]);
        });
    }
    
  2. Custom Test Execution Extend the TestManager class to add pre/post hooks:

    use Cmoclyn\TestManager\TestManager as BaseTestManager;
    
    class CustomTestManager extends BaseTestManager
    {
        protected function beforeRun(string $suite): void
        {
            // Pre-run logic (e.g., DB setup)
        }
    
        protected function afterRun(string $suite): void
        {
            // Post-run logic (e.g., cleanup)
        }
    }
    
  3. Artisan Command Overrides Override default commands in app/Console/Kernel.php:

    protected $commands = [
        \Cmoclyn\TestManager\Console\RunTests::class,
        // Custom commands...
    ];
    
  4. API Endpoints (Optional) Expose test results via Laravel routes:

    Route::get('/test-results/{suite}', [TestManagerController::class, 'show']);
    

Gotchas and Tips

Pitfalls

  1. Configuration Overrides

    • Ensure config/test-manager.php paths are absolute (use base_path()).
    • Avoid hardcoding paths in the config file; use environment variables or Laravel helpers.
  2. Bootstrap Files

    • If tests fail due to missing classes, verify bootstrap.php includes:
      require __DIR__.'/../../../vendor/autoload.php';
      $app = require __DIR__.'/../../../bootstrap/app.php';
      
  3. Parallel Testing

    • The package does not natively support parallel runs. Use php-parallel-lint or Laravel’s pest for parallelism.
  4. Caching Issues

    • Clear config cache after updates:
      php artisan config:clear
      

Debugging Tips

  • Verbose Output: Add --verbose to Artisan commands:
    php artisan test:run unit --verbose
    
  • Log Test Events: Extend TestManager to log execution:
    protected function logRun(string $suite, string $status): void
    {
        \Log::info("Suite [$suite] status: [$status]");
    }
    

Extension Points

  1. Custom Test Filters Add filters in TestManager:

    public function getFilteredTests(string $suite, array $filters = []): array
    {
        return array_filter($this->suites[$suite]['tests'], function ($test) use ($filters) {
            return !isset($filters['group']) || in_array($test['group'], $filters['group']);
        });
    }
    
  2. Plugin System Use Laravel’s service providers to inject custom test runners:

    $this->app->bind('test-runner', function () {
        return new CustomTestRunner();
    });
    
  3. Database Transactions Wrap test suites in transactions (if not using Laravel’s built-in support):

    protected function beforeRun(string $suite): void
    {
        DB::beginTransaction();
    }
    
    protected function afterRun(string $suite): void
    {
        DB::rollBack();
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware