Skip to content

Commit 7c06b54

Browse files
Replace dms/phpunit-arraysubset-assert
1 parent a572fae commit 7c06b54

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"php": "^7.2"
3030
},
3131
"require-dev": {
32-
"dms/phpunit-arraysubset-asserts": "^0.1.0",
3332
"kint-php/kint": "^3.1",
3433
"mockery/mockery": "^1.2",
3534
"orchestra/testbench": "^3.8",

tests/Assert.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SebastiaanLuca\BooleanDates\Tests;
6+
7+
use ArrayAccess;
8+
use PHPUnit\Framework\Assert as PHPUnit;
9+
use PHPUnit\Framework\Constraint\ArraySubset;
10+
use PHPUnit\Util\InvalidArgumentHelper;
11+
12+
class Assert extends PHPUnit
13+
{
14+
/**
15+
* Asserts that an array has a specified subset.
16+
*
17+
* This method was taken over from PHPUnit where it was deprecated. See link for more info.
18+
*
19+
* @param array|\ArrayAccess $subset
20+
* @param array|\ArrayAccess $array
21+
* @param bool $checkForObjectIdentity
22+
* @param string $message
23+
*
24+
* @return void
25+
*
26+
* @throws \Exception
27+
*
28+
* @link https://github.com/sebastianbergmann/phpunit/issues/3494
29+
*/
30+
public static function assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = '') : void
31+
{
32+
if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
33+
throw InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
34+
}
35+
36+
if (! (is_array($array) || $array instanceof ArrayAccess)) {
37+
throw InvalidArgumentHelper::factory(2, 'array or ArrayAccess');
38+
}
39+
40+
$constraint = new ArraySubset($subset, $checkForObjectIdentity);
41+
42+
static::assertThat($array, $constraint, $message);
43+
}
44+
}

tests/Feature/BooleanArrayTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
namespace SebastiaanLuca\BooleanDates\Tests\Feature;
66

77
use Carbon\Carbon;
8-
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
8+
use SebastiaanLuca\BooleanDates\Tests\Assert;
99
use SebastiaanLuca\BooleanDates\Tests\resources\TestModel;
1010
use SebastiaanLuca\BooleanDates\Tests\TestCase;
1111

1212
class BooleanArrayTest extends TestCase
1313
{
14-
use ArraySubsetAsserts;
15-
1614
/**
1715
* @test
1816
*/
@@ -61,7 +59,7 @@ public function it returns all attributes() : void
6159
'agreed_to_something_at' => null,
6260
];
6361

64-
static::assertArraySubset(
62+
Assert::assertArraySubset(
6563
$expected,
6664
$model->toArray()
6765
);

0 commit comments

Comments
 (0)