File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1414/** @covers \Budgegeria\IntlSort\Comparator\CallableAccess */
1515class CallableAccessTest extends TestCase
1616{
17- public function testDelegateToCollator (): void
17+ public function testCollatorWithFunction (): void
1818 {
1919 $ func = static function (mixed $ value ): string {
2020 assert (is_array ($ value ));
@@ -31,4 +31,25 @@ public function testDelegateToCollator(): void
3131
3232 self ::assertSame (-1 , $ comparator ->compare (['foo ' => '1 ' ], ['foo ' => '2 ' ]));
3333 }
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+ }
3455}
You can’t perform that action at this time.
0 commit comments