File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 14
14
/** @covers \Budgegeria\IntlSort\Comparator\CallableAccess */
15
15
class CallableAccessTest extends TestCase
16
16
{
17
- public function testDelegateToCollator (): void
17
+ public function testCollatorWithFunction (): void
18
18
{
19
19
$ func = static function (mixed $ value ): string {
20
20
assert (is_array ($ value ));
@@ -31,4 +31,25 @@ public function testDelegateToCollator(): void
31
31
32
32
self ::assertSame (-1 , $ comparator ->compare (['foo ' => '1 ' ], ['foo ' => '2 ' ]));
33
33
}
34
+
35
+ public function testCollatorWithClass (): void
36
+ {
37
+ $ func = new class {
38
+ public function __invoke (mixed $ value ): string
39
+ {
40
+ assert (is_array ($ value ));
41
+
42
+ return (string ) $ value ['foo ' ];
43
+ }
44
+ };
45
+ $ collator = self ::createMock (Collator::class);
46
+ $ collator ->expects (self ::once ())
47
+ ->method ('compare ' )
48
+ ->with ('1 ' , '2 ' )
49
+ ->willReturn (-1 );
50
+
51
+ $ comparator = new CallableAccess ($ collator , $ func );
52
+
53
+ self ::assertSame (-1 , $ comparator ->compare (['foo ' => '1 ' ], ['foo ' => '2 ' ]));
54
+ }
34
55
}
You can’t perform that action at this time.
0 commit comments