mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge pull request #1051 from krencl/fix-cache-directory-config-override
Fix cache directory config override
This commit is contained in:
@ -30,10 +30,12 @@ final class Cache implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public function handleArguments(array $arguments): array
|
public function handleArguments(array $arguments): array
|
||||||
{
|
{
|
||||||
$arguments = $this->pushArgument(
|
if (! $this->hasArgument('--cache-directory', $arguments)) {
|
||||||
sprintf('--cache-directory=%s', realpath(self::TEMPORARY_FOLDER)),
|
$arguments = $this->pushArgument(
|
||||||
$arguments
|
sprintf('--cache-directory=%s', realpath(self::TEMPORARY_FOLDER)),
|
||||||
);
|
$arguments
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->hasArgument('--parallel', $arguments)) {
|
if (! $this->hasArgument('--parallel', $arguments)) {
|
||||||
return $this->pushArgument('--cache-result', $arguments);
|
return $this->pushArgument('--cache-result', $arguments);
|
||||||
|
|||||||
@ -16,7 +16,17 @@ trait HandleArguments
|
|||||||
*/
|
*/
|
||||||
public function hasArgument(string $argument, array $arguments): bool
|
public function hasArgument(string $argument, array $arguments): bool
|
||||||
{
|
{
|
||||||
return in_array($argument, $arguments, true);
|
foreach ($arguments as $arg) {
|
||||||
|
if ($arg === $argument) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_starts_with($arg, "$argument=")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1212,6 +1212,14 @@
|
|||||||
PASS Tests\Unit\Overrides\ThrowableBuilder
|
PASS Tests\Unit\Overrides\ThrowableBuilder
|
||||||
✓ collision editor can be added to the stack trace
|
✓ collision editor can be added to the stack trace
|
||||||
|
|
||||||
|
PASS Tests\Unit\Plugins\Concerns\HandleArguments
|
||||||
|
✓ method hasArgument with ('--long-argument', true)
|
||||||
|
✓ method hasArgument with ('-a', true)
|
||||||
|
✓ method hasArgument with ('--with-equal-sign', true)
|
||||||
|
✓ method hasArgument with ('someValue', true)
|
||||||
|
✓ method hasArgument with ('--a', false)
|
||||||
|
✓ method hasArgument with ('--undefined-argument', false)
|
||||||
|
|
||||||
PASS Tests\Unit\Plugins\Environment
|
PASS Tests\Unit\Plugins\Environment
|
||||||
✓ environment is set to CI when --ci option is used
|
✓ environment is set to CI when --ci option is used
|
||||||
✓ environment is set to Local when --ci option is not used
|
✓ environment is set to Local when --ci option is not used
|
||||||
@ -1364,4 +1372,4 @@
|
|||||||
WARN Tests\Visual\Version
|
WARN Tests\Visual\Version
|
||||||
- visual snapshot of help command output
|
- visual snapshot of help command output
|
||||||
|
|
||||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 970 passed (2296 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 976 passed (2302 assertions)
|
||||||
26
tests/Unit/Plugins/Concerns/HandleArguments.php
Normal file
26
tests/Unit/Plugins/Concerns/HandleArguments.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?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],
|
||||||
|
]);
|
||||||
@ -16,7 +16,7 @@ $run = function () {
|
|||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
expect($run('--exclude-group=integration'))
|
expect($run('--exclude-group=integration'))
|
||||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 957 passed (2277 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 963 passed (2283 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user