mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 17:57:23 +01:00
tests: refactors toBeTruthy and toBeFalsy
This commit is contained in:
19
tests/Features/Expect/toBeTruthy.php
Normal file
19
tests/Features/Expect/toBeTruthy.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('passes as truthy', function ($value) {
|
||||
expect($value)->toBeTruthy();
|
||||
})->with([true, [1], 'false', 1, -1]);
|
||||
|
||||
test('passes as not truthy', function ($value) {
|
||||
expect($value)->not->toBeTruthy();
|
||||
})->with([false, '', null, 0, '0']);
|
||||
|
||||
test('failures', function () {
|
||||
expect(null)->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1)->not->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
Reference in New Issue
Block a user