mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8b785f69e | |||
| 56610d886d | |||
| be0d9e964b | |||
| 6bc9da3fe1 | |||
| 6f54462070 |
@ -19,7 +19,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"brianium/paratest": "^7.2.7",
|
"brianium/paratest": "^7.2.7",
|
||||||
"nunomaduro/collision": "^7.8.1",
|
"nunomaduro/collision": "^7.9.0",
|
||||||
"nunomaduro/termwind": "^1.15.1",
|
"nunomaduro/termwind": "^1.15.1",
|
||||||
"pestphp/pest-plugin": "^2.1.1",
|
"pestphp/pest-plugin": "^2.1.1",
|
||||||
"pestphp/pest-plugin-arch": "^2.3.3",
|
"pestphp/pest-plugin-arch": "^2.3.3",
|
||||||
|
|||||||
@ -1128,4 +1128,17 @@ final class Expectation
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value is between 2 specified values
|
||||||
|
*
|
||||||
|
* @return self<TValue>
|
||||||
|
*/
|
||||||
|
public function toBeBetween(int|float|DateTimeInterface $lowestValue, int|float|DateTimeInterface $highestValue, string $message = ''): self
|
||||||
|
{
|
||||||
|
Assert::assertGreaterThanOrEqual($lowestValue, $this->value, $message);
|
||||||
|
Assert::assertLessThanOrEqual($highestValue, $this->value, $message);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.19.1';
|
return '2.20.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -254,11 +254,11 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
|
|
||||||
private function destroyWorker(int $token): void
|
private function destroyWorker(int $token): void
|
||||||
{
|
{
|
||||||
// Mutation Testing tells us that the following `unset()` already destroys
|
|
||||||
// the `WrapperWorker`, which destroys the Symfony's `Process`, which
|
|
||||||
// automatically calls `Process::stop` within `Process::__destruct()`.
|
|
||||||
// But we prefer to have an explicit stops.
|
|
||||||
$this->workers[$token]->stop();
|
$this->workers[$token]->stop();
|
||||||
|
// We need to wait for ApplicationForWrapperWorker::end to end
|
||||||
|
while ($this->workers[$token]->isRunning()) {
|
||||||
|
usleep(self::CYCLE_SLEEP);
|
||||||
|
}
|
||||||
|
|
||||||
unset($this->workers[$token]);
|
unset($this->workers[$token]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.19.1.
|
Pest Testing Framework 2.20.0.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.19.1.
|
Pest Testing Framework 2.20.0.
|
||||||
|
|
||||||
|
|||||||
@ -332,6 +332,18 @@
|
|||||||
✓ pass
|
✓ pass
|
||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with custom message
|
✓ failures with custom message
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Features\Expect\toBeBetween
|
||||||
|
✓ passes with int
|
||||||
|
✓ passes with float
|
||||||
|
✓ passes with float and int
|
||||||
|
✓ passes with DateTime
|
||||||
|
✓ failure with int
|
||||||
|
✓ failure with float
|
||||||
|
✓ failure with float and int
|
||||||
|
✓ failure with DateTime
|
||||||
|
✓ failures with custom message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toBeBool
|
PASS Tests\Features\Expect\toBeBool
|
||||||
@ -1333,4 +1345,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, 943 passed (2224 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 953 passed (2269 assertions)
|
||||||
43
tests/Features/Expect/toBeBetween.php
Normal file
43
tests/Features/Expect/toBeBetween.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('passes with int', function () {
|
||||||
|
expect(2)->toBeBetween(1, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('passes with float', function () {
|
||||||
|
expect(1.5)->toBeBetween(1.25, 1.75);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('passes with float and int', function () {
|
||||||
|
expect(1.5)->toBeBetween(1, 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('passes with DateTime', function () {
|
||||||
|
expect(new DateTime('2023-09-22'))->toBeBetween(new DateTime('2023-09-21'), new DateTime('2023-09-23'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failure with int', function () {
|
||||||
|
expect(4)->toBeBetween(1, 3);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failure with float', function () {
|
||||||
|
expect(2)->toBeBetween(1.5, 1.75);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failure with float and int', function () {
|
||||||
|
expect(2.1)->toBeBetween(1, 2);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failure with DateTime', function () {
|
||||||
|
expect(new DateTime('2023-09-20'))->toBeBetween(new DateTime('2023-09-21'), new DateTime('2023-09-23'));
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failures with custom message', function () {
|
||||||
|
expect(4)->toBeBetween(1, 3, 'oh no!');
|
||||||
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect(2)->not->toBeBetween(1, 3);
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
@ -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, 932 passed (2209 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 942 passed (2254 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user