PHP code example of sergey-bel / phpinvariant
1. Go to this page and download the library: Download sergey-bel/phpinvariant library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sergey-bel / phpinvariant example snippets
class IntegerInvariant extends BaseInvariant
{
// run check method 10 times
#[FinishRuns(10)]
public function checkInteger()
{
// $x is a random integer in [50, 100]
$x = $this->provider->integer(50, 100)->get();
$this->assertTrue(is_integer($x));
// fail when $x=100
$this->assertLessOrEqual($x, 99);
$this->assertGreaterOrEqual($x, 50);
}
}
$this->provider
->string(5, 10)
->alphabetic()
->get();