Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ public static function email(mixed $value, string $message = ''): string

/**
* Does non-strict comparisons on the items, so ['3', 3] will not pass the assertion.
* Note: objects with identical properties are also considered equal.
*
* @throws InvalidArgumentException
*/
Expand Down
21 changes: 21 additions & 0 deletions tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static function getTests(): array
$normalList = ['foo' => 'b', 3];
unset($normalList['foo']);

$a = new ToStringClass('testString');
$b = new ToStringClass('testString');
$c = new ToStringClass('otherString');

return [
['string', ['value'], true],
['string', [''], true],
Expand Down Expand Up @@ -251,6 +255,9 @@ public static function getTests(): array
['eq', [1, '1'], true],
['eq', [1, true], true],
['eq', [1, 0], false],
['eq', [$a, $a], true],
['eq', [$a, $b], true],
['eq', [$a, $c], false],
['notEq', [1, 0], true],
['notEq', [1, 1], false],
['notEq', [1, '1'], false],
Expand All @@ -259,10 +266,14 @@ public static function getTests(): array
['same', [1, '1'], false],
['same', [1, true], false],
['same', [1, 0], false],
['same', [$a, $b], false],
['same', [$a, $a], true],
['notSame', [1, 0], true],
['notSame', [1, 1], false],
['notSame', [1, '1'], true],
['notSame', [1, true], true],
['notSame', [$a, $b], true],
['notSame', [$a, $a], false],
['greaterThan', [1, 0], true],
['greaterThan', [0, 0], false],
['greaterThanEq', [2, 1], true],
Expand All @@ -283,8 +294,15 @@ public static function getTests(): array
['notOneOf', [1, ['1', '2', '3']], true],
['inArray', [1, [1, 2, 3]], true],
['inArray', [1, ['1', '2', '3']], false],
['inArray', [$a, [$a]], true],
['inArray', [$a, [(string) $a]], false],
['inArray', [$a, [$b]], false],
['inArray', [$a, [$c]], false],
['notInArray', [1, [1, 2, 3]], false],
['notInArray', [1, ['1', '2', '3']], true],
['notInArray', [$a, [$a]], false],
['notInArray', [$a, [$b]], true],
['notInArray', [$a, [$c]], true],
['contains', ['abcd', 'ab'], true],
['contains', ['abcd', 'bc'], true],
['contains', ['abcd', 'cd'], true],
Expand Down Expand Up @@ -628,6 +646,9 @@ public static function getTests(): array
['uniqueValues', [['qwerty', 'qwerty']], false],
['uniqueValues', [['asdfg', 'qwerty']], true],
['uniqueValues', [[123, '123']], false],
['uniqueValues', [[$a, $a]], false],
['uniqueValues', [[$a, $b]], false],
['uniqueValues', [[$a, $c]], true],
['isStatic', [static function () {}], true],
['isStatic', [function () {}], false],
['notStatic', [static function () {}], false],
Expand Down
Loading