feat: allow string type in gt/lt expectations

This commit is contained in:
Pauls Nartišs
2024-01-05 16:06:54 +02:00
parent dc1e4f040d
commit b1c59ec2e6
6 changed files with 28 additions and 4 deletions

View File

@ -16,6 +16,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
expect($past)->not->toBeGreaterThan($now);
});
test('passes with strings', function () {
expect('b')->toBeGreaterThan('a');
expect('a')->not->toBeGreaterThan('a');
});
test('failures', function () {
expect(4)->toBeGreaterThan(4);
})->throws(ExpectationFailedException::class);

View File

@ -18,6 +18,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
expect($past)->not->toBeGreaterThanOrEqual($now);
});
test('passes with strings', function () {
expect('b')->toBeGreaterThanOrEqual('a');
expect('a')->toBeGreaterThanOrEqual('a');
});
test('failures', function () {
expect(4)->toBeGreaterThanOrEqual(4.1);
})->throws(ExpectationFailedException::class);

View File

@ -16,6 +16,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
expect($now)->not->toBeLessThan($now);
});
test('passes with strings', function () {
expect('a')->toBeLessThan('b');
expect('a')->not->toBeLessThan('a');
});
test('failures', function () {
expect(4)->toBeLessThan(4);
})->throws(ExpectationFailedException::class);

View File

@ -18,6 +18,11 @@ test('passes with DateTime and DateTimeImmutable', function () {
expect($now)->not->toBeLessThanOrEqual($past);
});
test('passes with strings', function () {
expect('a')->toBeLessThanOrEqual('b');
expect('a')->toBeLessThanOrEqual('a');
});
test('failures', function () {
expect(4)->toBeLessThanOrEqual(3.9);
})->throws(ExpectationFailedException::class);