Skip to content

Commit fa0d5f3

Browse files
committed
added tests for sorted
1 parent 66f6790 commit fa0d5f3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/Unit/CypherListTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,18 @@ public function testJoinEmpty(): void
334334
{
335335
self::assertEquals('', (new CypherList())->join('A'));
336336
}
337+
338+
public function testSortedDefault(): void
339+
{
340+
self::assertEquals($this->list, $this->list->sorted());
341+
self::assertEquals($this->list, $this->list->reversed()->sorted());
342+
}
343+
344+
public function testSortedCustom(): void
345+
{
346+
$sorted = $this->list->sorted(static fn (string $x, $y) => -1 * ($x <=> $y));
347+
348+
self::assertEquals(new CypherList(['C', 'B', 'A']), $sorted);
349+
self::assertEquals(new CypherList(['A', 'B', 'C']), $this->list);
350+
}
337351
}

0 commit comments

Comments
 (0)