Skip to content

Commit e8f7d45

Browse files
imanghafoori1taylorotwell
authored andcommitted
add test for sorted middlewares (#30166)
1 parent dcbfaf0 commit e8f7d45

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/Routing/RoutingSortedMiddlewareTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,24 @@ public function testMiddlewareCanBeSortedByPriority()
4444
$this->assertEquals([], (new SortedMiddleware(['First'], []))->all());
4545
$this->assertEquals(['First'], (new SortedMiddleware(['First'], ['First']))->all());
4646
$this->assertEquals(['First', 'Second'], (new SortedMiddleware(['First', 'Second'], ['Second', 'First']))->all());
47+
}
4748

49+
public function testItDoesNotMoveNonStringValues()
50+
{
4851
$closure = function () {
49-
//
52+
return 'foo';
5053
};
54+
55+
$closure2 = function () {
56+
return 'bar';
57+
};
58+
59+
$this->assertEquals([2, 1], (new SortedMiddleware([1, 2], [2, 1]))->all());
5160
$this->assertEquals(['Second', $closure], (new SortedMiddleware(['First', 'Second'], ['Second', $closure]))->all());
61+
$this->assertEquals(['a', 'b', $closure], (new SortedMiddleware(['a', 'b'], ['b', $closure, 'a']))->all());
62+
$this->assertEquals([$closure2, 'a', 'b', $closure, 'foo'], (new SortedMiddleware(['a', 'b'], [$closure2, 'b', $closure, 'a', 'foo']))->all());
63+
$this->assertEquals([$closure, 'a', 'b', $closure2, 'foo'], (new SortedMiddleware(['a', 'b'], [$closure, 'b', $closure2, 'foo', 'a']))->all());
64+
$this->assertEquals(['a', $closure, 'b', $closure2, 'foo'], (new SortedMiddleware(['a', 'b'], ['a', $closure, 'b', $closure2, 'foo']))->all());
65+
$this->assertEquals([$closure, $closure2, 'foo', 'a'], (new SortedMiddleware(['a', 'b'], [$closure, $closure2, 'foo', 'a']))->all());
5266
}
5367
}

0 commit comments

Comments
 (0)