PHP code example of alezhu / phpunit-array-contains-asserts

1. Go to this page and download the library: Download alezhu/phpunit-array-contains-asserts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alezhu / phpunit-array-contains-asserts example snippets


use Alezhu\PHPUnitArrayContainsAsserts\Assert;
use PHPUnit\Framework\Assert as PHPUnitAssert;

//Passed
Assert::assertArrayContains(
    [
        "foo" => PHPUnitAssert::isString(), 
        "baz" => 1
    ], 
    [
        "foo" => "value",
        "bar" => true, 
        "baz" => 1
    ]
); 
//Not Passed
Assert::assertArrayContains(
    [
        "foo" => PHPUnitAssert::isString(), 
        "baz" => 1
    ], 
    [
        "foo" => "bar", 
    ]
); 

use Alezhu\PHPUnitArrayContainsAsserts\Assert;
use PHPUnit\Framework\Assert as PHPUnitAssert;

//Passed
Assert::assertArrayContainsOnly(
    [
        "foo" => PHPUnitAssert::isString(), 
        "baz" => 1
    ], 
    [
        "foo" => "value",
        "baz" => 1
    ]
); 
//Not Passed
Assert::assertArrayContainsOnly(
    [
        "foo" => PHPUnitAssert::isString(), 
        "baz" => 1
    ], 
    [
        "foo" => "bar",
        "bar" => true, 
        "baz" => 1         
    ]
);