Files
pest/tests/Unit/Plugins/Concerns/HandleArguments.php
flap152 8467c64c22 fix: popArgument drops duplicate arguments breaking --parallel --exclude-gropup= (#1674)
* fix: popArgument drops duplicate arguments breaking --parallel multi-exclude-group

Fixes #1437

* fix: ensure popArgument handles duplicate arguments

* fix: update expected test results and snapshots after rebase

---------

Signed-off-by: nuno maduro <enunomaduro@gmail.com>
Co-authored-by: nuno maduro <enunomaduro@gmail.com>
2026-06-12 17:58:37 +01:00

51 lines
1.4 KiB
PHP

<?php
use Pest\Plugins\Concerns\HandleArguments;
test('method hasArgument', function (string $argument, bool $expectedResult) {
$obj = new class
{
use HandleArguments;
};
$arguments = [
'--long-argument',
'someValue',
'-a',
'--with-equal-sign=1337',
];
expect($obj->hasArgument($argument, $arguments))->toBe($expectedResult);
})->with([
['--long-argument', true],
['-a', true],
['--with-equal-sign', true],
['someValue', true],
['--a', false],
['--undefined-argument', false],
]);
test('popArgument preserves duplicate values when removing a missing argument', function () {
$obj = new class
{
use HandleArguments;
};
$arguments = ['--verbose', '--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest'];
$result = $obj->popArgument('--missingitem', $arguments);
expect($result)->toBe($arguments);
});
test('popArgument preserves duplicate values when removing an existing argument', function () {
$obj = new class
{
use HandleArguments;
};
$arguments = ['--verbose', '--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest'];
$result = $obj->popArgument('--verbose', $arguments);
expect($result)->toBe(['--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest']);
});