Including tests for Date and DateTimeImmutable

This commit is contained in:
Dan Ang
2023-03-21 14:37:31 +01:00
parent ecbaff503e
commit a8bd353ba6
6 changed files with 46 additions and 2 deletions

View File

@ -334,12 +334,14 @@
PASS Tests\Features\Expect\toBeGreatherThan
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeGreatherThanOrEqual
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
✓ failures with custom message
✓ not failures
@ -382,12 +384,14 @@
PASS Tests\Features\Expect\toBeLessThan
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeLessThanOrEqual
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
✓ failures with custom message
✓ not failures
@ -944,4 +948,4 @@
PASS Tests\Visual\Version
✓ visual snapshot of help command output
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1588 assertions)
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 653 passed (1604 assertions)

View File

@ -7,6 +7,15 @@ test('passes', function () {
expect(4)->toBeGreaterThan(3.9);
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
expect($now)->toBeGreaterThan($past);
expect($past)->not->toBeGreaterThan($now);
});
test('failures', function () {
expect(4)->toBeGreaterThan(4);
})->throws(ExpectationFailedException::class);

View File

@ -7,6 +7,17 @@ test('passes', function () {
expect(4)->toBeGreaterThanOrEqual(4);
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
expect($now)->toBeGreaterThanOrEqual($now);
expect($now)->toBeGreaterThanOrEqual($past);
expect($past)->not->toBeGreaterThanOrEqual($now);
});
test('failures', function () {
expect(4)->toBeGreaterThanOrEqual(4.1);
})->throws(ExpectationFailedException::class);

View File

@ -7,6 +7,15 @@ test('passes', function () {
expect(4)->toBeLessThan(5);
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
expect($past)->toBeLessThan($now);
expect($now)->not->toBeLessThan($now);
});
test('failures', function () {
expect(4)->toBeLessThan(4);
})->throws(ExpectationFailedException::class);

View File

@ -7,6 +7,17 @@ test('passes', function () {
expect(4)->toBeLessThanOrEqual(4);
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
expect($now)->toBeLessThanOrEqual($now);
expect($past)->toBeLessThanOrEqual($now);
expect($now)->not->toBeLessThanOrEqual($past);
});
test('failures', function () {
expect(4)->toBeLessThanOrEqual(3.9);
})->throws(ExpectationFailedException::class);

View File

@ -15,6 +15,6 @@ $run = function () {
};
test('parallel', function () use ($run) {
expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 640 passed (1576 assertions)')
expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 644 passed (1592 assertions)')
->toContain('Parallel: 3 processes');
})->skip(PHP_OS_FAMILY === 'Windows');