The assertGreaterThan() is a built in PHP function to test your php based features before deploying the application on your live application.
Syntax:
1 | assertGreaterThan(mixed $expected, mixed $actual[, string $message = '']) |
1 2 3 4 5 6 7 8 9 10 11 12 | <?php use PHPUnit\Framework\TestCase; class GreaterThanTest extends TestCase { public function testFailure() { $expected = 2; $real_value = 1; $this->assertGreaterThan( $expected, $real_value ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | PHPUnit 8.4.0 by Sebastian Bergmann and contributors. F 1 / 1 (100%) Time: 2.07 seconds, Memory: 44.50 MB There was 1 failure: 1) GreaterThanTest::testFailure Failed asserting that 1 is greater than 2. /var/www/html/tests/phpunit/test.php:10 FAILURES! Tests: 1, Assertions: 1, Failures: 1. |
1 2 3 4 5 6 7 8 9 10 11 12 | <?php use PHPUnit\Framework\TestCase; class GreaterThanTest extends TestCase { public function testFailure() { $expected = 2; $real_value = 3; $this->assertGreaterThan( $expected, $real_value ); } } |
1 2 3 4 5 6 7 | PHPUnit 8.4.0 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 2.19 seconds, Memory: 44.50 MB OK (1 test, 1 assertion) |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.