PHPUnit assertGreaterThanOrEqual() Function
The assertGreaterThanOrEqual() function is a builtin function in PHPUnit and is used to assert whether the actually obtained value is greater than or equal to the expected value or not. This assertion will return true in the case if the actual value is greater than or equal to the expected value else returns false. In case of true the asserted test case got passed else test case got failed.
assertGreaterThanOrEqual(mixed $expected, mixed $actual [, string $message = ''])
Parameters: This function accepts three parameters as mentioned above and described below:
- $expected: This parameter is of any type of numeric value which represents the expected data.
- $actual: This parameter is of any type of numeric value which represents the actual data.
- $message: This parameter takes a string value. When the test case got failed this string message got displayed as an error message.
Below examples illustrate the assertGreaterThanOrEqual() function in PHPUnit:
PHPUnit 8.5.8 by Sebastian Bergmann and contributors. FF 2 / 2 (100%) Time: 86 ms, Memory: 10.00 MB There were 2 failures: 1) GeeksPhpunitTestCase::testNegativeForassertGreaterThanOrEqualWithEqualVal actual value is greater than or equal to expected Failed asserting that 10 is equal to 22 or is greater than 22. /home/lovely/Documents/php/test.php:15 2) GeeksPhpunitTestCase::testNegativeForassertGreaterThanOrEqualWithGreaterVal actual value is greater than or equal to expected Failed asserting that 11 is equal to 22 or is greater than 22. /home/lovely/Documents/php/test.php:32 FAILURES! Tests: 2, Assertions: 4, Failures: 2.
PHPUnit 8.5.8 by Sebastian Bergmann and contributors. .. 2 / 2 (100%) Time: 87 ms, Memory: 10.00 MB OK (2 tests, 4 assertions)
My Personal Notes arrow_drop_up
Please Login to comment...