diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 6d723876..71117657 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -131,7 +131,7 @@ final class Expectation * * @return self */ - public function toBeGreaterThan(int|float|DateTimeInterface $expected, string $message = ''): self + public function toBeGreaterThan(int|float|string|DateTimeInterface $expected, string $message = ''): self { Assert::assertGreaterThan($expected, $this->value, $message); @@ -143,7 +143,7 @@ final class Expectation * * @return self */ - public function toBeGreaterThanOrEqual(int|float|DateTimeInterface $expected, string $message = ''): self + public function toBeGreaterThanOrEqual(int|float|string|DateTimeInterface $expected, string $message = ''): self { Assert::assertGreaterThanOrEqual($expected, $this->value, $message); @@ -155,7 +155,7 @@ final class Expectation * * @return self */ - public function toBeLessThan(int|float|DateTimeInterface $expected, string $message = ''): self + public function toBeLessThan(int|float|string|DateTimeInterface $expected, string $message = ''): self { Assert::assertLessThan($expected, $this->value, $message); @@ -167,7 +167,7 @@ final class Expectation * * @return self */ - public function toBeLessThanOrEqual(int|float|DateTimeInterface $expected, string $message = ''): self + public function toBeLessThanOrEqual(int|float|string|DateTimeInterface $expected, string $message = ''): self { Assert::assertLessThanOrEqual($expected, $this->value, $message); diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index cd53e6fd..fbec75e2 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -430,6 +430,7 @@ PASS Tests\Features\Expect\toBeGreaterThan ✓ passes ✓ passes with DateTime and DateTimeImmutable + ✓ passes with strings ✓ failures ✓ failures with custom message ✓ not failures @@ -437,6 +438,7 @@ PASS Tests\Features\Expect\toBeGreaterThanOrEqual ✓ passes ✓ passes with DateTime and DateTimeImmutable + ✓ passes with strings ✓ failures ✓ failures with custom message ✓ not failures @@ -494,6 +496,7 @@ PASS Tests\Features\Expect\toBeLessThan ✓ passes ✓ passes with DateTime and DateTimeImmutable + ✓ passes with strings ✓ failures ✓ failures with custom message ✓ not failures @@ -501,6 +504,7 @@ PASS Tests\Features\Expect\toBeLessThanOrEqual ✓ passes ✓ passes with DateTime and DateTimeImmutable + ✓ passes with strings ✓ failures ✓ failures with custom message ✓ not failures diff --git a/tests/Features/Expect/toBeGreaterThan.php b/tests/Features/Expect/toBeGreaterThan.php index a3ceafef..f59c6628 100644 --- a/tests/Features/Expect/toBeGreaterThan.php +++ b/tests/Features/Expect/toBeGreaterThan.php @@ -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); diff --git a/tests/Features/Expect/toBeGreaterThanOrEqual.php b/tests/Features/Expect/toBeGreaterThanOrEqual.php index 4a0f62ad..52aa3b18 100644 --- a/tests/Features/Expect/toBeGreaterThanOrEqual.php +++ b/tests/Features/Expect/toBeGreaterThanOrEqual.php @@ -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); diff --git a/tests/Features/Expect/toBeLessThan.php b/tests/Features/Expect/toBeLessThan.php index 802c1c08..f7de96fa 100644 --- a/tests/Features/Expect/toBeLessThan.php +++ b/tests/Features/Expect/toBeLessThan.php @@ -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); diff --git a/tests/Features/Expect/toBeLessThanOrEqual.php b/tests/Features/Expect/toBeLessThanOrEqual.php index e5643759..f25f0774 100644 --- a/tests/Features/Expect/toBeLessThanOrEqual.php +++ b/tests/Features/Expect/toBeLessThanOrEqual.php @@ -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);