mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c8970e0a3 | |||
| 2f2b51ce3d | |||
| 33f596bcce | |||
| 50a96dcb8f | |||
| d9a4fa33b9 | |||
| 1c673fcff9 | |||
| ff82596158 | |||
| 0539d2ba62 | |||
| 1915ad368a | |||
| a4833bbfe4 | |||
| 7433cc5565 | |||
| 4c769fac66 |
@ -2,6 +2,13 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## [v2.2.3 (2023-03-24)](https://github.com/pestphp/pest/compare/v2.2.2...v2.2.3)
|
||||
|
||||
### Fixed
|
||||
- Unnecessary dataset on dataset arguments missmatch ([#736](https://github.com/pestphp/pest/pull/736))
|
||||
- Parallel arguments on plugins order ([#703](https://github.com/pestphp/pest/pull/703))
|
||||
- Arch plugin runtime exceptions on bad phpdocs ([2f2b51c](https://github.com/pestphp/pest/commit/2f2b51ce3d1b000be9d6add0e785fd0044931b3b))
|
||||
|
||||
## [v2.2.2 (2023-03-23)](https://github.com/pestphp/pest/compare/v2.2.1...v2.2.2)
|
||||
|
||||
### Fixed
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
"brianium/paratest": "^7.1.2",
|
||||
"nunomaduro/collision": "^7.3.3",
|
||||
"nunomaduro/termwind": "^1.15.1",
|
||||
"pestphp/pest-plugin": "^2.0.0",
|
||||
"pestphp/pest-plugin-arch": "^2.0.1",
|
||||
"pestphp/pest-plugin": "^2.0.1",
|
||||
"pestphp/pest-plugin-arch": "^2.0.2",
|
||||
"phpunit/phpunit": "^10.0.18"
|
||||
},
|
||||
"conflict": {
|
||||
|
||||
@ -2,7 +2,7 @@ ARG PHP=8.1
|
||||
FROM php:${PHP}-cli-alpine
|
||||
|
||||
RUN apk update \
|
||||
&& apk add zip libzip-dev icu-dev
|
||||
&& apk add zip libzip-dev icu-dev git
|
||||
|
||||
RUN docker-php-ext-configure zip
|
||||
RUN docker-php-ext-install zip
|
||||
|
||||
@ -241,7 +241,7 @@ trait Testable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($testParameterTypes[$argumentIndex], [\Closure::class, 'callable', 'mixed'])) {
|
||||
if (in_array($testParameterTypes[$argumentIndex], [Closure::class, 'callable', 'mixed'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ trait Testable
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
if (in_array($testParameterTypes[0], [\Closure::class, 'callable'])) {
|
||||
if (in_array($testParameterTypes[0], [Closure::class, 'callable'])) {
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ trait Testable
|
||||
return;
|
||||
}
|
||||
|
||||
throw new DatasetArgsCountMismatch($this->dataName(), $requiredParametersCount, $suppliedParametersCount);
|
||||
throw new DatasetArgsCountMismatch($requiredParametersCount, $suppliedParametersCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Pest\Contracts\Plugins;
|
||||
interface HandlesArguments
|
||||
{
|
||||
/**
|
||||
* Adds arguments before of the Test Suite execution.
|
||||
* Adds arguments before the Test Suite execution.
|
||||
*
|
||||
* @param array<int, string> $arguments
|
||||
* @return array<int, string>
|
||||
|
||||
@ -8,8 +8,8 @@ use Exception;
|
||||
|
||||
final class DatasetArgsCountMismatch extends Exception
|
||||
{
|
||||
public function __construct(string $dataName, int $requiredCount, int $suppliedCount)
|
||||
public function __construct(int $requiredCount, int $suppliedCount)
|
||||
{
|
||||
parent::__construct(sprintf('Test expects %d arguments but dataset [%s] only provides %d', $requiredCount, $dataName, $suppliedCount));
|
||||
parent::__construct(sprintf('Test expects %d arguments but dataset only provides %d', $requiredCount, $suppliedCount));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace Pest;
|
||||
|
||||
function version(): string
|
||||
{
|
||||
return '2.2.2';
|
||||
return '2.2.3';
|
||||
}
|
||||
|
||||
function testDirectory(string $file = ''): string
|
||||
|
||||
@ -14,15 +14,16 @@ use Pest\Support\Arr;
|
||||
use Pest\Support\Container;
|
||||
use Pest\TestSuite;
|
||||
use function Pest\version;
|
||||
use Stringable;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
final class Parallel implements HandlesArguments
|
||||
{
|
||||
use HandleArguments;
|
||||
|
||||
private const GLOBAL_PREFIX = 'PEST_PARALLEL_GLOBAL_';
|
||||
|
||||
private const HANDLERS = [
|
||||
Parallel\Handlers\Parallel::class,
|
||||
Parallel\Handlers\Pest::class,
|
||||
@ -59,6 +60,33 @@ final class Parallel implements HandlesArguments
|
||||
return ((int) $argvValue) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a global value that can be accessed by the parent process and all workers.
|
||||
*/
|
||||
public static function setGlobal(string $key, string|int|bool|Stringable $value): void
|
||||
{
|
||||
$data = ['value' => $value instanceof Stringable ? $value->__toString() : $value];
|
||||
|
||||
$_ENV[self::GLOBAL_PREFIX.$key] = json_encode($data, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the given global value if one has been set.
|
||||
*/
|
||||
public static function getGlobal(string $key): string|int|bool|null
|
||||
{
|
||||
$placesToCheck = [$_SERVER, $_ENV];
|
||||
|
||||
foreach ($placesToCheck as $location) {
|
||||
if (array_key_exists(self::GLOBAL_PREFIX.$key, $location)) {
|
||||
// @phpstan-ignore-next-line
|
||||
return json_decode((string) $location[self::GLOBAL_PREFIX.$key], true, 512, JSON_THROW_ON_ERROR)['value'] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -86,12 +114,6 @@ final class Parallel implements HandlesArguments
|
||||
*/
|
||||
private function runTestSuiteInParallel(array $arguments): int
|
||||
{
|
||||
if (! class_exists(ParaTestCommand::class)) {
|
||||
$this->askUserToInstallParatest();
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$handlers = array_filter(
|
||||
array_map(fn ($handler): object|string => Container::getInstance()->get($handler), self::HANDLERS),
|
||||
fn ($handler): bool => $handler instanceof HandlesArguments,
|
||||
@ -128,20 +150,6 @@ final class Parallel implements HandlesArguments
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a message to the user asking them to install ParaTest as a dev dependency.
|
||||
*/
|
||||
private function askUserToInstallParatest(): void
|
||||
{
|
||||
/** @var OutputInterface $output */
|
||||
$output = Container::getInstance()->get(OutputInterface::class);
|
||||
|
||||
$output->writeln([
|
||||
'<fg=red>Pest Parallel requires ParaTest to run.</>',
|
||||
'Please run <fg=yellow>composer require --dev brianium/paratest</>.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an instance of the Paratest command.
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
Pest Testing Framework 2.2.2.
|
||||
Pest Testing Framework 2.2.3.
|
||||
|
||||
USAGE: pest <file> [options]
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
|
||||
Pest Testing Framework 2.2.2.
|
||||
Pest Testing Framework 2.2.3.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user