diff --git a/src/Assert.php b/src/Assert.php index c5b954f..2a86f93 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -50,6 +50,44 @@ public static function notSame(mixed $expected, mixed $actual, string $message = )); } + /** + * Asserts that the condition is true. + * + * @param bool $condition The condition asserting to be true. + * @param string $message Short description about what exactly is being asserted. + * @throws AssertException when the assertion fails. + */ + public static function true(bool $condition, string $message = ''): void + { + $condition === true + ? StaticState::log('Assert true', $message) + : StaticState::fail(AssertException::compare( + true, + $condition, + $message, + 'Failed asserting that value `%2$s` is `%1$s`.', + )); + } + + /** + * Asserts that the condition is false. + * + * @param bool $condition The condition asserting to be false. + * @param string $message Short description about what exactly is being asserted. + * @throws AssertException when the assertion fails. + */ + public static function false(bool $condition, string $message = ''): void + { + $condition === false + ? StaticState::log('Assert false', $message) + : StaticState::fail(AssertException::compare( + false, + $condition, + $message, + 'Failed asserting that value `%2$s` is `%1$s`.', + )); + } + /** * Asserts that the given value is null. * diff --git a/tests/Testo/AsserTest.php b/tests/Testo/AsserTest.php index 58ef16a..e7e5212 100644 --- a/tests/Testo/AsserTest.php +++ b/tests/Testo/AsserTest.php @@ -17,6 +17,8 @@ public function simpleAssertions(): void Assert::same(1, 1); Assert::null(null); Assert::notSame(42, '42'); + Assert::true(true); + Assert::false(false); } #[Test]