Add toBeTruthy

This commit is contained in:
Esteban
2021-08-03 20:54:56 -04:00
parent ce7a7649a2
commit cffde4564d
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('passes', function () {
expect(true)->toBeTruthy();
expect([1])->toBeTruthy();
expect('false')->toBeTruthy();
expect(1)->toBeTruthy();
expect(-1)->toBeTruthy();
expect(false)->not->toBeTruthy();
expect('')->not->toBeTruthy();
expect(null)->not->toBeTruthy();
expect([])->not->toBeTruthy();
expect(0)->not->toBeTruthy();
expect('0')->not->toBeTruthy();
});
test('failures', function () {
expect(null)->toBeTruthy();
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect(1)->not->toBeTruthy();
})->throws(ExpectationFailedException::class);