https://github.com/adhocore/asserts
More PHPUnit assertions as a Trait
https://github.com/adhocore/asserts
adhocore array-subset assertions asserts json-subset phpunit
Last synced: 16 days ago
JSON representation
More PHPUnit assertions as a Trait
- Host: GitHub
- URL: https://github.com/adhocore/asserts
- Owner: adhocore
- License: mit
- Created: 2019-02-05T16:51:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-09-26T15:45:10.000Z (over 2 years ago)
- Last Synced: 2025-03-28T17:01:45.640Z (about 1 month ago)
- Topics: adhocore, array-subset, assertions, asserts, json-subset, phpunit
- Language: PHP
- Homepage: https://github.com/adhocore/asserts
- Size: 20.5 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## adhocore/asserts
[](https://github.com/adhocore/asserts/releases)
[](https://travis-ci.com/adhocore/asserts?branch=master)
[](https://scrutinizer-ci.com/g/adhocore/asserts/?branch=master)
[](https://codecov.io/gh/adhocore/asserts)
[](https://styleci.io/repos/169276368)
[](./LICENSE)## Installation
```bash
composer require --dev adhocore/asserts
```## Usage
```php
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',
]
);
}
}
```## Contributing
Please check [the guide](./CONTRIBUTING.md)
## LICENSE
> © [MIT](./LICENSE) | 2019, Jitendra Adhikari