mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
35 lines
931 B
PHP
35 lines
931 B
PHP
<?php
|
|
|
|
use PHPUnit\Framework\ExpectationFailedException;
|
|
|
|
test('passes', function () {
|
|
expect(42)->toBeGreaterThan(41);
|
|
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('passes with strings', function () {
|
|
expect('b')->toBeGreaterThan('a');
|
|
expect('a')->not->toBeGreaterThan('a');
|
|
});
|
|
|
|
test('failures', function () {
|
|
expect(4)->toBeGreaterThan(4);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('failures with custom message', function () {
|
|
expect(4)->toBeGreaterThan(4, 'oh no!');
|
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
|
|
|
test('not failures', function () {
|
|
expect(5)->not->toBeGreaterThan(4);
|
|
})->throws(ExpectationFailedException::class);
|