You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b7e48fc
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ All options do the same, the only difference is that the static class and trait
33
33
34
34
The `AssociativeArray` constraint asserts that a value is an associative array matching a given structure and that the array's items pass other constraints.
35
35
36
-
Any native array and `ArrayAccess` object is considered an associative array, no matter which keys they use. However, the array's items are applied to the matching constraint (parameter `$consotraints`). By default, additional items will fail the constraint (parameter `$allowAdditional`, defaults to `false`). The same is true when items are missing (parameter `$allowMissing`, defaults to `false`). The expected keys and constraints to apply, as well as whether additional and/or missing items should fail the constraint, are passed in the constructor.
36
+
Any native array and `ArrayAccess` object is considered an associative array, no matter which keys they use. However, the array's items are applied to the matching constraint (parameter `$consotraints`). By default, missing items will fail the constraint (parameter `$allowMissing`, defaults to `false`). Additional items will be ignored by default (parameter `$allowAdditional`, defaults to `true`). If you want the constraint to fail when additional items exist, set this option to `true`, however, please note that this works for native arrays only. The expected keys and constraints to apply, as well as whether missing and/or additional items should fail the constraint, are passed in the constructor.
37
37
38
38
**Usage:**
39
39
@@ -42,16 +42,16 @@ Any native array and `ArrayAccess` object is considered an associative array, no
42
42
self::assertAssociativeArray(
43
43
array $constraints, // an associative array with the expected keys and constraints to apply
44
44
array|ArrayAccess $array, // the associative array to check
45
-
bool $allowAdditional = false, // whether additional items should fail the constraint
46
45
bool $allowMissing = false, // whether missing items should fail the constraint
46
+
bool $allowAdditional = true, // whether additional items should fail the constraint
47
47
string $message = '' // additional information about the test
48
48
);
49
49
50
50
// using new instance of `\PhrozenByte\PHPUnitArrayAsserts\Constraint\AssociativeArray`
51
51
new AssociativeArray(
52
52
array $constraints,
53
-
bool $allowAdditional = false,
54
-
bool $allowMissing = false
53
+
bool $allowMissing = false,
54
+
bool $allowAdditional = true
55
55
);
56
56
```
57
57
@@ -236,13 +236,13 @@ class MyTest extends TestCase
0 commit comments