An open API service indexing awesome lists of open source software.

https://github.com/codekandis/phpunit

`codekandis/phpunit` is a library providing an enhanced test case wrapper with additional constraint assertions for `PhpUnit`.
https://github.com/codekandis/phpunit

classes helper library php phpunit wrapper

Last synced: 2 days ago
JSON representation

`codekandis/phpunit` is a library providing an enhanced test case wrapper with additional constraint assertions for `PhpUnit`.

Awesome Lists containing this project

README

          

# codekandis/phpunit

[![Version][xtlink-version-badge]][srclink-changelog]
[![License][xtlink-license-badge]][srclink-license]
[![Minimum PHP Version][xtlink-php-version-badge]][xtlink-php-net]
![Code Coverage][xtlink-code-coverage-badge]

`codekandis/phpunit` is a library providing an enhanced test case wrapper with additional constraint assertions for
[`phpunit/phpunit`][xtlink-packagist-phpunit-phpunit].

## Index

* [Installation](#installation)
* [Usage](#usage)
* [Using the test case wrapper](#using-the-test-case-wrapper)
* [Using the data provider interface](#using-the-data-provider-interface)
* [Asserting array subsets](#asserting-array-subsets)
* [`TestCase::assertArrayContainsKeyedSubset()`](#testcaseassertarraycontainskeyedsubset)
* [`TestCase::assertArrayContainsUnkeyedSubset()`](#testcaseassertarraycontainsunkeyedsubset)
* [`TestCase::assertIsKeyedSubsetOfArray()`](#testcaseassertiskeyedsubsetofarray)
* [`TestCase::assertIsUnkeyedSubsetOfArray()`](#testcaseassertisunkeyedsubsetofarray)
* [Asserting subclass relationships](#asserting-subclass-relationships)
* [`TestCase::assertIsSubClassOf()`](#testcaseassertissubclassof)

## Installation

Install the latest version with

```bash
$ composer require --dev codekandis/phpunit
```

## Usage

### Using the test case wrapper

Create a test case that extends the `TestCase` wrapper.

The additional constraint assertions are available through this wrapper.

```php
[
23,
42
],
1 => [
'foo',
'bar'
]
];
}
}
```

Use the data provider in your test case.

```php
[
'bar' => 23
]
],
[
'foo' => [
'bar' => 23,
'baz' => 42
]
],
true
);
}
}
```

#### `TestCase::assertArrayContainsUnkeyedSubset()`

Use `TestCase::assertArrayContainsUnkeyedSubset()` to assert that `$actualArray` contains the values of
`$expectedSubset` without comparing keys. Set `$strict` to `true` to compare values strictly, or to `false` to compare
values loosely.

```php
[
'bar' => 23,
'baz' => 42
]
],
[
'foo' => [
'bar' => 23
]
],
true
);
}
}
```

#### `TestCase::assertIsUnkeyedSubsetOfArray()`

Use `TestCase::assertIsUnkeyedSubsetOfArray()` to assert that the values of `$actualSubset` are contained in
`$expectedArray` without comparing keys. Set `$strict` to `true` to compare values strictly, or to `false` to compare
values loosely.

```php