PHPackages                             dms/phpunit-arraysubset-asserts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. dms/phpunit-arraysubset-asserts

ActiveLibrary[Testing &amp; Quality](/categories/testing)

dms/phpunit-arraysubset-asserts
===============================

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

v0.5.0(2y ago)14327.7M—1.3%32[3 issues](https://github.com/rdohms/phpunit-arraysubset-asserts/issues)[8 PRs](https://github.com/rdohms/phpunit-arraysubset-asserts/pulls)20MITPHPPHP ^5.4 || ^7.0 || ^8.0

Since Feb 17Pushed 1y ago9 watchersCompare

[ Source](https://github.com/rdohms/phpunit-arraysubset-asserts)[ Packagist](https://packagist.org/packages/dms/phpunit-arraysubset-asserts)[ RSS](/packages/dms-phpunit-arraysubset-asserts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (16)Used By (20)

PHPUnit AssertArraySubset Extension
===================================

[](#phpunit-assertarraysubset-extension)

In PHPUnit 8 the function `assertArraySubset` was [deprecated](https://github.com/sebastianbergmann/phpunit/issues/3494). This function was often misunderstood and thus removed, but it still holds true as a very useful tool, hence it was extracted here.

**Disclaimer:**The initial version contained here is copied over from phpunit and is heavily based on the original work by [Márcio Almada](https://github.com/marcioAlmada).

Installation
------------

[](#installation)

Simply use it by importing it with Composer

```
composer require --dev dms/phpunit-arraysubset-asserts

```

> 💡 The package can be safely required on PHP 5.4 to current in combination with PHPUnit 4.8.36/5.7.21 to current.
>
> When the PHPUnit `assertArraySubset()` method is natively available and not deprecated (PHPUnit 4.x - 7.x), the PHPUnit native functionality will be used. For PHPUnit 8 and higher, the extension will kick in and polyfill the functionality which was removed from PHPUnit.

Usage
-----

[](#usage)

You have two options to use this in your classes: either directly as a static call or as a trait if you wish to keep existing references working.

### Trait use example

[](#trait-use-example)

```
