File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
tests/WS/Utils/Collections Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ public function sortBy(callable $extractor): Stream
137137 sort ($ values );
138138 $ newList = $ this ->emptyList ();
139139 foreach ($ values as $ value ) {
140- $ els = $ map [$ value ] ?? [];
140+ $ els = $ map [$ value. '' ] ?? [];
141141 $ newList ->addAll ($ els );
142142 }
143143 $ this ->list = $ newList ;
Original file line number Diff line number Diff line change 88use Exception ;
99use PHPUnit \Framework \TestCase ;
1010use WS \Utils \Collections \UnitConstraints \CollectionIsEqual ;
11+ use WS \Utils \Collections \Utils \ExampleObject ;
1112use WS \Utils \Collections \Utils \InvokeCounter ;
1213use WS \Utils \Collections \Utils \TestInteger ;
1314
@@ -502,6 +503,23 @@ public function sortingWithNotScalarValue(): void
502503 ;
503504 }
504505
506+ /**
507+ * @test
508+ */
509+ public function sortingWithSingleValue (): void
510+ {
511+ $ obj = new ExampleObject ();
512+ $ obj ->property = 1.12 ;
513+ $ sortedFirstElement = $ this ->createCollection ([$ obj ])
514+ ->stream ()
515+ ->sortBy (static function (ExampleObject $ object ) {
516+ return $ object ->property ;
517+ })
518+ ->findFirst ()
519+ ;
520+ self ::assertNotNull ($ sortedFirstElement );
521+ }
522+
505523 /**
506524 * @dataProvider sortCases
507525 * @test
You can’t perform that action at this time.
0 commit comments