Compare commits

..

13 Commits

Author SHA1 Message Date
b58a020423 release: v1.22.3 2022-12-07 14:31:55 +00:00
e337a52cda Merge pull request #612 from alexmanase/1.x-fix-ignored-description-for-layz-datasets
[1.x] Fixes ignored dataset description only for string description
2022-12-07 14:23:55 +00:00
0a6873d8a6 wip 2022-11-17 16:14:03 +02:00
09b7ab9a42 fixes ignored dataset description for string description 2022-11-17 15:43:30 +02:00
339414e348 release: v1.22.2 2022-11-09 21:10:57 +00:00
bb56d32643 chore: fixes coding style issues 2022-11-09 21:08:19 +00:00
acd6bb2234 Merge pull request #602 from alexmanase/fix/iterator-to-array
[1.x] Fix storing of lazy datasets into internal array
2022-11-09 20:59:19 +00:00
cf93e316ff chore: bumps dependencies 2022-11-09 20:09:40 +00:00
47cc88a6ab add tests for eager registered wrapped datasets with Generator functions 2022-10-30 01:35:46 +03:00
45bf9e8650 ignore the keys returned by the datasets Generator for storing them into an array 2022-10-29 18:19:43 +03:00
3c766c15d5 Updates dependencies 2022-09-18 14:21:38 +01:00
aa407f34d5 Merge pull request #575 from fabio-ivona/1.x-fix-tests
1.x fix tests
2022-09-12 18:21:07 +02:00
077b5ffce0 fix tests 2022-09-12 18:18:52 +02:00
15 changed files with 94 additions and 32 deletions

View File

@ -20,6 +20,11 @@ $rules = [
],
'concat_space' => ['spacing' => 'one'],
'not_operator_with_space' => false,
'global_namespace_import' => [
'import_classes' => true,
'import_functions' => true,
'import_constants' => true,
],
];
$rules['increment_style'] = ['style' => 'post'];

View File

@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [v1.22.3 (2022-12-07)](https://github.com/pestphp/pest/compare/v1.22.2...v1.22.3)
### Fixed
- Fixes ignoring datasets description on lazy datasets ([#612](https://github.com/pestphp/pest/pull/612))
## [v1.22.2 (2022-11-09)](https://github.com/pestphp/pest/compare/v1.22.1...v1.22.2)
### Fixed
- Fixes storing lazy datasets into internal array ([#602](https://github.com/pestphp/pest/pull/602))
## [v1.22.1 (2022-08-29)](https://github.com/pestphp/pest/compare/v1.22.0...v1.22.1)
### Fixed
- Initial PHP 8.2 support ([d050ef8](https://github.com/pestphp/pest/commit/d050ef8d54ffe8dfe015adeb1188aae2cca33c33))

View File

@ -18,9 +18,9 @@
],
"require": {
"php": "^7.3 || ^8.0",
"nunomaduro/collision": "^5.10.0|^6.0",
"pestphp/pest-plugin": "^1.0.0",
"phpunit/phpunit": "^9.5.5"
"nunomaduro/collision": "^5.11.0|^6.3.0",
"pestphp/pest-plugin": "^1.1.0",
"phpunit/phpunit": "^9.5.26"
},
"autoload": {
"psr-4": {
@ -40,11 +40,11 @@
]
},
"require-dev": {
"illuminate/console": "^8.47.0",
"illuminate/support": "^8.47.0",
"laravel/dusk": "^6.15.0",
"pestphp/pest-dev-tools": "dev-master",
"pestphp/pest-plugin-parallel": "^1.0"
"illuminate/console": "^8.83.26",
"illuminate/support": "^8.83.26",
"laravel/dusk": "^6.25.2",
"pestphp/pest-dev-tools": "^1.0.0",
"pestphp/pest-plugin-parallel": "^1.2"
},
"minimum-stability": "dev",
"prefer-stable": true,

View File

@ -90,11 +90,6 @@ parameters:
count: 1
path: src/Expectation.php
-
message: "#^Parameter \\#1 \\$actualJson of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertJson\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Expectation.php
-
message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryExists\\(\\) expects string, mixed given\\.$#"
count: 1
@ -250,16 +245,6 @@ parameters:
count: 1
path: src/Support/ExceptionTrace.php
-
message: "#^Cannot access offset 'file' on mixed\\.$#"
count: 1
path: src/Support/ExceptionTrace.php
-
message: "#^Parameter \\#1 \\$haystack of function mb_strpos expects string, mixed given\\.$#"
count: 1
path: src/Support/ExceptionTrace.php
-
message: "#^Parameter \\#2 \\$array of function key_exists expects array, mixed given\\.$#"
count: 1

View File

@ -9,6 +9,9 @@ use Pest\Support\ChainableClosure;
use Pest\Support\ExceptionTrace;
use Pest\TestSuite;
use PHPUnit\Framework\ExecutionOrderDependency;
use function sprintf;
use Throwable;
/**
@ -257,7 +260,7 @@ trait Testable
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'%s::%s',
self::$__filename,
$this->__description

View File

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Pest\Console;
use function is_dir;
use Pest\Actions\AddsDefaults;
use Pest\Actions\AddsTests;
use Pest\Actions\InteractsWithPlugins;
@ -81,7 +83,7 @@ final class Command extends BaseCommand
$testSuite = $this->arguments['test'];
if (is_string($testSuite)) {
if (\is_dir($testSuite)) {
if (is_dir($testSuite)) {
/** @var string[] $files */
$files = (new FileIteratorFacade())->getFilesAsArray(
$testSuite,

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest;
use Closure;
use Generator;
use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist;
use SebastianBergmann\Exporter\Exporter;
@ -122,7 +123,10 @@ final class Datasets
}
if ($datasets[$index] instanceof Traversable) {
$datasets[$index] = iterator_to_array($datasets[$index]);
$preserveKeysForArrayIterator = $datasets[$index] instanceof Generator
&& is_string($datasets[$index]->key());
$datasets[$index] = iterator_to_array($datasets[$index], $preserveKeysForArrayIterator);
}
foreach ($datasets[$index] as $key => $values) {

View File

@ -86,6 +86,7 @@ final class TeamCity extends DefaultResultPrinter
foreach ($filteredResults as $key => $info) {
$this->writeWithColor($info['color'], $info['count'] . " $key", false);
/* @phpstan-ignore-next-line */
if ($key !== array_reverse(array_keys($filteredResults))[0]) {
$this->write(', ');
}

View File

@ -102,7 +102,7 @@ final class TestCall
* Runs the current test multiple times with
* each item of the given `iterable`.
*
* @param array<\Closure|iterable<int|string, mixed>|string> $data
* @param array<Closure|iterable<int|string, mixed>|string> $data
*/
public function with(...$data): TestCall
{

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '1.22.1';
return '1.22.3';
}
function testDirectory(string $file = ''): string

View File

@ -44,7 +44,6 @@ final class ExceptionTrace
*/
public static function removePestReferences(Throwable $t): void
{
/* @phpstan-ignore-next-line */
if (!property_exists($t, 'serializableTrace')) {
return;
}

View File

@ -5,6 +5,9 @@ declare(strict_types=1);
namespace Pest\Support;
use Closure;
use const PHP_MAJOR_VERSION;
use ReflectionClass;
use Throwable;
@ -132,7 +135,7 @@ final class HigherOrderMessage
private static function getUndefinedMethodMessage(object $target, string $methodName): string
{
if (\PHP_MAJOR_VERSION >= 8) {
if (PHP_MAJOR_VERSION >= 8) {
return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName)));
}

View File

@ -96,6 +96,13 @@
✓ more than two datasets with (2) / (4) / (5)
✓ more than two datasets with (2) / (4) / (6)
✓ more than two datasets did the job right
✓ eager registered wrapped datasets with Generator functions with (1)
✓ eager registered wrapped datasets with Generator functions with (2)
✓ eager registered wrapped datasets with Generator functions with (3)
✓ eager registered wrapped datasets with Generator functions with (4)
✓ eager registered wrapped datasets with Generator functions did the job right
✓ eager registered wrapped datasets with Generator functions display description with data set "taylor"
✓ eager registered wrapped datasets with Generator functions display description with data set "james"
✓ it can resolve a dataset after the test case is available with (Closure Object (...))
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #1
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #2
@ -722,5 +729,5 @@
✓ it is a test
✓ it uses correct parent class
Tests: 4 incompleted, 9 skipped, 480 passed
Tests: 4 incompleted, 9 skipped, 487 passed

View File

@ -13,3 +13,20 @@ dataset('numbers.closure.wrapped', function () {
dataset('numbers.array', [[1], [2]]);
dataset('numbers.array.wrapped', [1, 2]);
dataset('numbers.generators.wrapped', function () {
yield from firstSetOfNumber();
yield from secondSetOfNumbers();
});
function firstSetOfNumber(): Generator
{
yield 1;
yield 2;
}
function secondSetOfNumbers(): Generator
{
yield 3;
yield 4;
}

View File

@ -228,10 +228,38 @@ test('more than two datasets did the job right', function () use ($state) {
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
});
$wrapped_generator_state = new stdClass();
$wrapped_generator_state->text = '';
$wrapped_generator_function_datasets = [1, 2, 3, 4];
test(
'eager registered wrapped datasets with Generator functions',
function (int $text) use (
$wrapped_generator_state,
$wrapped_generator_function_datasets
) {
$wrapped_generator_state->text .= $text;
expect(in_array($text, $wrapped_generator_function_datasets))->toBe(true);
}
)->with('numbers.generators.wrapped');
test('eager registered wrapped datasets with Generator functions did the job right', function () use ($wrapped_generator_state) {
expect($wrapped_generator_state->text)->toBe('1234');
});
test('eager registered wrapped datasets with Generator functions display description', function ($wrapped_generator_state_with_description) {
expect($wrapped_generator_state_with_description)->not->toBeEmpty();
})->with(function () {
yield 'taylor' => 'taylor@laravel.com';
yield 'james' => 'james@laravel.com';
});
it('can resolve a dataset after the test case is available', function ($result) {
expect($result)->toBe('bar');
})->with([
function () { return $this->foo; },
function () {
return $this->foo;
},
]);
it('can resolve a dataset after the test case is available with shared yield sets', function ($result) {