All Projects → rdohms → Phpunit Arraysubset Asserts

rdohms / Phpunit Arraysubset Asserts

Licence: mit
Provides assertArraySubset for use in PHPunit

Projects that are alternatives of or similar to Phpunit Arraysubset Asserts

Coveragechecker
Allows old code to use new standards
Stars: ✭ 159 (+67.37%)
Mutual labels:  hacktoberfest, phpunit
Paraunit
Run PHPUnit tests in parallel
Stars: ✭ 104 (+9.47%)
Mutual labels:  hacktoberfest, phpunit
Haskell Music
Source Code from "Making Music with Haskell" video
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Sign Android Release
A GitHub action to sign an APK or AAB
Stars: ✭ 93 (-2.11%)
Mutual labels:  hacktoberfest
Image To Ascii
💾 A Node.js module that converts images to ASCII art.
Stars: ✭ 1,328 (+1297.89%)
Mutual labels:  hacktoberfest
Kotlinfixture
Fixtures for Kotlin providing generated values for unit testing
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Geocalc
Geographic calculations for Elixir
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Adyen Php Api Library
Adyen API Library for PHP
Stars: ✭ 93 (-2.11%)
Mutual labels:  hacktoberfest
Hashtagify
📸 Generates hashtags for Instagram posts. Upload your photo and it will suggest the relevant #hashtags for you. 🏷
Stars: ✭ 95 (+0%)
Mutual labels:  hacktoberfest
Marshmallow Oneofschema
Marshmallow library extension that allows schema (de)multiplexing
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Awesome Bupt Scs
北京邮电大学计算机学院本科编程作业索引
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Bitalarm
An app to keep track of different cryptocurrencies, written in dart + flutter
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Hotel booking app
🏩 📑 ❤️ Demo application for hotel booking app made with @flutter and love.
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Bootstrap Navbar Dropdowns
Bootstrap 4 Navbar with multiple dropdowns
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Laravel Make Scope
Brings make:scope command to laravel
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Quasar Apexcharts
📊 📈 📉 Project using Quasar framework and ApexCharts.
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Plexdrive
Plexdrive mounts your Google Drive FUSE filesystem (optimized for media playback)
Stars: ✭ 1,324 (+1293.68%)
Mutual labels:  hacktoberfest
Polybar Kdeconnect
KDEConnect module for Polybar
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Awesome Wordpress Developer Tips
Curated list that contain code, snippets or examples without libraries or external packages for developers.
Stars: ✭ 94 (-1.05%)
Mutual labels:  hacktoberfest
Dts2hx
Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
Stars: ✭ 95 (+0%)
Mutual labels:  hacktoberfest

PHPUnit AssertArraySubset Extension

In PHPUnit 8 the function assertArraySubset was deprecated. 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.

Installation

Simply use it by importing it with Composer

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

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.

<?php
declare(strict_types=1);

namespace DMS\Tests;

use DMS\PHPUnitExtensions\ArraySubset\Assert;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use PHPUnit\Framework\TestCase;


final class AssertTest extends TestCase
{
    use ArraySubsetAsserts;
    
    public function testWithTrait(): void
    {
        $expectedSubset = ['bar' => 0];

        $content = ['bar' => '0'];

        self::assertArraySubset($expectedSubset, $content, true);
    }

    public function testWithDirectCall(): void
    {
        $expectedSubset = ['bar' => 0];

        $content = ['bar' => '0'];

        Assert::assertArraySubset($expectedSubset, $content, true);
    }
}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].