Testing `laminas-cli` module commands

I migrated some commands to laminas-cli for a module we use in various projects.

I can run ./vendor/bin/laminas module:command from the projects that import the module without a problem, so that’s good :slight_smile:

However, I’m struggling with figuring out a good way to run CI tests in the module itself. I want to run the commands in CI.

Does anyone have any suggestions? It looks like the laminas command supports --container=, however, I’m not sure how to make it without making another Application itself.

If you follow the skeleton application then you already have a container:

<?php

/**
 * This file provides a container for `laminas-cli`
 *
 * 1. Copy `config/laminas-cli.config.php.dist` to `config/laminas-cli.config.php`
 * 2. Edit the config file you just copied with the appropriate keys
 * 3. Run `./vendor/bin/laminas -vvv --container=bin/container.php`
 */

use Laminas\Mvc\Application;

$app = Application::init([
    'modules' => [
        'Laminas\Log',
        'Laminas\Router',
        // More modules here
    ],
    'module_listener_options' => [
        'use_laminas_loader' => false,
        'config_cache_enabled' => false,
        'config_static_paths' => [
            __DIR__ . '/../config/laminas-cli.config.php',
        ],
    ],
]);
return $app->getServiceManager();

I added laminas-mvc as a dev requirement, and it worked for me, thanks! :slight_smile: