gerardroche / sublime-phpunit

PHPUnit Sublime Text integration.
https://www.gerardroche.com
GNU General Public License v3.0
74 stars 11 forks source link

Add custom strategies #124

Open gerardroche opened 1 year ago

gerardroche commented 1 year ago

Re https://github.com/gerardroche/sublime-phpunit/issues/92#issuecomment-1665030486

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.