Skip to content

Add custom strategies #124

@gerardroche

Description

@gerardroche

Re #92 (comment)

Allow creation of custom strategies.

Since 3.17.1 you can roughly create custom strategies.

Example: Custom cmd.exe strategy

Command Palette → Preferences: PHPUnit Settings

{
    "phpunit.prepend_cmd": ["cmd.exe", "/c"]
    "phpunit.strategy": "external"
}

The "external" strategy is available since 3.17.1 and prevent the exec output
panel from opening.

A better api might be something like:

{
    "phpunit.strategy_cmd": ["cmd.exe", "/c"],
    "phpunit.strategy": "external"
}

Or simply:

{
    "phpunit.strategy": ["cmd.exe", "/c"]
}

That is to say, if the "phpunit.strategy" setting is not a string, then it's
assumed to be a custom strategy.

This would then still allow us to configure the setting "phpunit.prepend_cmd",
but would prevent us reusing an existing strategy i.e. building on top of an
existing strategy.

{
    "phpunit.custom_strategies": {
        "my_win_strategy": ["cmd.exe", "/c"],
        "my_ps_strategy": ["ps.exe", "/c"],
    }
    "phpunit.strategy": "my_win_strategy"
}

Flexible.

{
    "phpunit.custom_strategies": {
        "my_win_strategy": {
            "command": ["cmd.exe", "/c"]
        },
        "my_ps_strategy": {
            "command": ["ps.exe", "/c"]
        }
    }
    "phpunit.strategy": "my_win_strategy"
}

Allows for future configuration of strategies, should it be needed. Both of the
above could be valid.

The first just implies the command because the type of value is a list i.e. no
additional configuration for the strategy. The second opens up the possibility
of additional strategy configuration, if avaiable in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions