@@ -119,6 +119,28 @@ public function testAddChildrenMethodReturnsSelf()
119119 $ this ->assertSame ($ group , $ group ->add ([]));
120120 }
121121
122+ public function testItemsOrderingDefaultsToAddOrder ()
123+ {
124+ $ group = new NavigationGroup ('Group ' , [
125+ new NavigationItem (new Route (new MarkdownPage ()), 'Foo ' ),
126+ new NavigationItem (new Route (new MarkdownPage ()), 'Bar ' ),
127+ new NavigationItem (new Route (new MarkdownPage ()), 'Baz ' ),
128+ ]);
129+
130+ $ this ->assertSame (['Foo ' , 'Bar ' , 'Baz ' ], $ group ->getItems ()->map (fn (NavigationItem $ item ) => $ item ->getLabel ())->all ());
131+ }
132+
133+ public function testItemsAreSortedByPriority ()
134+ {
135+ $ group = new NavigationGroup ('Group ' , [
136+ new NavigationItem (new Route (new MarkdownPage ()), 'Foo ' , 3 ),
137+ new NavigationItem (new Route (new MarkdownPage ()), 'Bar ' , 2 ),
138+ new NavigationItem (new Route (new MarkdownPage ()), 'Baz ' , 1 ),
139+ ]);
140+
141+ $ this ->assertSame (['Baz ' , 'Bar ' , 'Foo ' ], $ group ->getItems ()->map (fn (NavigationItem $ item ) => $ item ->getLabel ())->all ());
142+ }
143+
122144 public function testGetPriorityUsesDefaultPriority ()
123145 {
124146 $ this ->assertSame (999 , (new NavigationGroup ('Foo ' ))->getPriority ());
0 commit comments