composer require --dev adhocore/asserts
use Ahc\Asserts\Asserts;
use PHPUnit\Framework\TestCase;
class MyTest extends Testcase
{
use Asserts;
public function testSomething()
{
$this->assertJsonSubset($expectedSubset, $actualJson);
$this->assertJsonSubsets($expectedSubset1, $expectedSubset2, ... , $actualJson);
$this->assertFloatEquals($expected = 1.66666666, $actual = 1.666666689, $precision = 4);
$this->assertArrayHasKeys($expected = ['a', 'b'], $actual = ['a' => 1, 'b' => 2]);
$this->assertIsAssocArray(['key' => 'value']);
$this->assertIsNotAssocArray([1, 2, 3, 4, 5]);
$this->assertFileIsExecutable('/bin/sh');
$this->assertFileIsNotExecutable('/bin/not-found');
$this->assertAll(
$expectations = [
'equals' => 1,
'lessThan' => 10,
'greaterThan' => 0,
],
$actual = 1,
$messages = [
'greaterThan' => 'Should be postitive number',
]
);
}
}
Please check the guide
© MIT | 2019, Jitendra Adhikari