Skip to content

Commit ab7001d

Browse files
committed
Update README
Added a backstory and some usage instructions to guide users.
1 parent dca69cc commit ab7001d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PHPUnit AssertArraySubset Extension
2+
3+
In PHPunit 8 the function `assertArraySubset` was [deprecated](https://github.com/sebastianbergmann/phpunit/issues/3494). This function was often misunderstood and this removed, but it still holds true as a very useful tool, hence it was extracted here.
4+
5+
**Disclaimer**
6+
The initial version contained here is copied over from phpunit and is heavilybased on the original work by [Márcio Almada](https://github.com/marcioAlmada)
7+
8+
## Installation
9+
10+
Simply use it by importing it with Composer
11+
12+
```
13+
composer require dms/phpunit-arraysubset-asserts
14+
```
15+
16+
## Usage
17+
18+
You have two options to use this in your classes, either directly as a static call or as a trait if you with to keep existing references working.
19+
20+
```php
21+
<?php
22+
declare(strict_types=1);
23+
24+
namespace DMS\Tests;
25+
26+
use DMS\PHPUnitExtensions\ArraySubset\Assert;
27+
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
28+
use PHPUnit\Framework\TestCase;
29+
30+
31+
final class AssertTest extends TestCase
32+
{
33+
use ArraySubsetAsserts;
34+
35+
public function testWithTrait(): void
36+
{
37+
self::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
38+
}
39+
40+
public function testWithDirectCall(): void
41+
{
42+
Assert::assertArraySubset(['bar' => 0], ['bar' => '0'], true);
43+
}
44+
}
45+
46+
```

0 commit comments

Comments
 (0)