mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 01:37:21 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55b9266648 | |||
| 4313a1ef20 | |||
| 005ef03845 | |||
| eb56483ba2 | |||
| 5d6b717c9a | |||
| 14859a4c89 | |||
| 8a44d3f136 | |||
| be71d6918d | |||
| afb3dd459a | |||
| b6e3ffafa7 | |||
| 6c95f3d8cf | |||
| 2192373bec | |||
| dfcdaa3f8e | |||
| 79bc9e677f | |||
| 60b615ea6a | |||
| 8787481e40 | |||
| c24406259f |
16
CHANGELOG.md
16
CHANGELOG.md
@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## [v2.16.0 (2023-08-21)](https://github.com/pestphp/pest/compare/v2.15.0...v2.16.0)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `toBeDigits` ([#911](https://github.com/pestphp/pest/pull/911))
|
||||||
|
- `toBeCamelCase`, `toBeKebabCase`, `toBeSnakeCase`, `toBeStudlyCase`, `toHaveSnakeCaseKeys`, `toHaveKebabCaseKeys`, `toHaveCamelCaseKeys`, `toHaveStudlyCaseKeys`` ([#921](https://github.com/pestphp/pest/pull/921))
|
||||||
|
- native functions support on `arch` expectations, e.g: `expect('sleep')->toBeUsed();` ([#4](https://github.com/pestphp/pest-plugin-arch/pull/4))
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `phpunit.xml` stub ([#915](https://github.com/pestphp/pest/pull/915))
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Nested sequences ([#895](https://github.com/pestphp/pest/pull/895))
|
||||||
|
|
||||||
## [v2.15.0 (2023-08-17)](https://github.com/pestphp/pest/compare/v2.14.1...v2.15.0)
|
## [v2.15.0 (2023-08-17)](https://github.com/pestphp/pest/compare/v2.14.1...v2.15.0)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -18,11 +18,11 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"brianium/paratest": "^7.2.5",
|
"brianium/paratest": "^7.2.6",
|
||||||
"nunomaduro/collision": "^7.8.1",
|
"nunomaduro/collision": "^7.8.1",
|
||||||
"nunomaduro/termwind": "^1.15.1",
|
"nunomaduro/termwind": "^1.15.1",
|
||||||
"pestphp/pest-plugin": "^2.0.1",
|
"pestphp/pest-plugin": "^2.1.1",
|
||||||
"pestphp/pest-plugin-arch": "^2.3.1",
|
"pestphp/pest-plugin-arch": "^2.3.3",
|
||||||
"phpunit/phpunit": "^10.3.2"
|
"phpunit/phpunit": "^10.3.2"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
@ -51,8 +51,8 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pestphp/pest-dev-tools": "^2.16.0",
|
"pestphp/pest-dev-tools": "^2.16.0",
|
||||||
"pestphp/pest-plugin-type-coverage": "^2.0.0",
|
"pestphp/pest-plugin-type-coverage": "^2.2.0",
|
||||||
"symfony/process": "^6.3.2"
|
"symfony/process": "^6.3.4"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace Pest\Mixins;
|
|||||||
|
|
||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Countable;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Error;
|
use Error;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
@ -264,7 +265,7 @@ final class Expectation
|
|||||||
public function toHaveCount(int $count, string $message = ''): self
|
public function toHaveCount(int $count, string $message = ''): self
|
||||||
{
|
{
|
||||||
if (! is_countable($this->value) && ! is_iterable($this->value)) {
|
if (! is_countable($this->value) && ! is_iterable($this->value)) {
|
||||||
InvalidExpectationValue::expected('string');
|
InvalidExpectationValue::expected('countable|iterable');
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert::assertCount($count, $this->value, $message);
|
Assert::assertCount($count, $this->value, $message);
|
||||||
@ -272,6 +273,23 @@ final class Expectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the size of the value and $expected are the same.
|
||||||
|
*
|
||||||
|
* @param Countable|iterable<mixed> $expected
|
||||||
|
* @return self<TValue>
|
||||||
|
*/
|
||||||
|
public function toHaveSameSize(Countable|iterable $expected, string $message = ''): self
|
||||||
|
{
|
||||||
|
if (! is_countable($this->value) && ! is_iterable($this->value)) {
|
||||||
|
InvalidExpectationValue::expected('countable|iterable');
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert::assertSameSize($expected, $this->value, $message);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value contains the property $name.
|
* Asserts that the value contains the property $name.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.16.0';
|
return '2.16.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Support;
|
namespace Pest\Support;
|
||||||
|
|
||||||
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@ -25,6 +27,10 @@ final class DatasetInfo
|
|||||||
|
|
||||||
public static function scope(string $file): string
|
public static function scope(string $file): string
|
||||||
{
|
{
|
||||||
|
if (Str::endsWith($file, testDirectory('Pest.php'))) {
|
||||||
|
return dirname($file);
|
||||||
|
}
|
||||||
|
|
||||||
if (self::isInsideADatasetsDirectory($file)) {
|
if (self::isInsideADatasetsDirectory($file)) {
|
||||||
return dirname($file, 2);
|
return dirname($file, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.16.0.
|
Pest Testing Framework 2.16.1.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.16.0.
|
Pest Testing Framework 2.16.1.
|
||||||
|
|
||||||
|
|||||||
@ -638,6 +638,7 @@
|
|||||||
|
|
||||||
PASS Tests\Features\Expect\toHaveCount
|
PASS Tests\Features\Expect\toHaveCount
|
||||||
✓ pass
|
✓ pass
|
||||||
|
✓ failures with invalid type
|
||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with message
|
✓ failures with message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
@ -722,6 +723,13 @@
|
|||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with message
|
✓ failures with message
|
||||||
✓ failures with message and Any matcher
|
✓ failures with message and Any matcher
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Features\Expect\toHaveSameSize
|
||||||
|
✓ failures with wrong type
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
|
✓ failures with message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toHaveSnakeCaseKeys
|
PASS Tests\Features\Expect\toHaveSnakeCaseKeys
|
||||||
@ -1007,6 +1015,9 @@
|
|||||||
✓ uses dataset with (1)
|
✓ uses dataset with (1)
|
||||||
✓ uses dataset with (2)
|
✓ uses dataset with (2)
|
||||||
✓ the right dataset is taken
|
✓ the right dataset is taken
|
||||||
|
✓ it can see datasets defined in Pest.php file with ('A')
|
||||||
|
✓ it can see datasets defined in Pest.php file with ('B')
|
||||||
|
✓ Pest.php dataset is taken
|
||||||
|
|
||||||
WARN Tests\Features\Skip
|
WARN Tests\Features\Skip
|
||||||
✓ it do not skips
|
✓ it do not skips
|
||||||
@ -1296,4 +1307,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, 916 passed (2190 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 925 passed (2204 assertions)
|
||||||
@ -1,11 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Pest\Exceptions\InvalidExpectationValue;
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect([1, 2, 3])->toHaveCount(3);
|
expect([1, 2, 3])->toHaveCount(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('failures with invalid type', function () {
|
||||||
|
expect('foo')->toHaveCount(3);
|
||||||
|
})->throws(InvalidExpectationValue::class, 'Invalid expectation value type. Expected [countable|iterable]');
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect([1, 2, 3])->toHaveCount(4);
|
expect([1, 2, 3])->toHaveCount(4);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
24
tests/Features/Expect/toHaveSameSize.php
Normal file
24
tests/Features/Expect/toHaveSameSize.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Pest\Exceptions\InvalidExpectationValue;
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('failures with wrong type', function () {
|
||||||
|
expect('foo')->toHaveSameSize([1]);
|
||||||
|
})->throws(InvalidExpectationValue::class, 'Invalid expectation value type. Expected [countable|iterable].');
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect([1, 2, 3])->toHaveSameSize([4, 5, 6]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect([1, 2, 3])->toHaveSameSize([1]);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failures with message', function () {
|
||||||
|
expect([1, 2, 3])->toHaveSameSize([1], 'oh no!');
|
||||||
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect([1, 2, 3])->not->toHaveSameSize([1]);
|
||||||
|
});
|
||||||
@ -10,3 +10,12 @@ test('uses dataset', function ($value) use ($state) {
|
|||||||
test('the right dataset is taken', function () use ($state) {
|
test('the right dataset is taken', function () use ($state) {
|
||||||
expect($state->text)->toBe('12');
|
expect($state->text)->toBe('12');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can see datasets defined in Pest.php file', function (string $value) use ($state) {
|
||||||
|
$state->text .= $value;
|
||||||
|
expect(true)->toBe(true);
|
||||||
|
})->with('dataset_in_pest_file');
|
||||||
|
|
||||||
|
test('Pest.php dataset is taken', function () use ($state) {
|
||||||
|
expect($state->text)->toBe('12AB');
|
||||||
|
});
|
||||||
|
|||||||
@ -37,3 +37,5 @@ function helper_returns_string()
|
|||||||
{
|
{
|
||||||
return 'string';
|
return 'string';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataset('dataset_in_pest_file', ['A', 'B']);
|
||||||
|
|||||||
@ -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, 905 passed (2175 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 914 passed (2189 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user