@@ -196,6 +196,31 @@ public function test_shelf_view_sort_takes_action()
196
196
$ this ->withHtml ($ resp )->assertElementContains ('.book-content a.grid-card:nth-child(3) ' , 'adsfsdfsdfsd ' );
197
197
}
198
198
199
+ public function test_shelf_view_sorts_by_name_case_insensitively ()
200
+ {
201
+ $ shelf = Bookshelf::query ()->whereHas ('books ' )->with ('books ' )->first ();
202
+ $ books = Book::query ()->take (3 )->get (['id ' , 'name ' ]);
203
+ $ books [0 ]->fill (['name ' => 'Book Ab ' ])->save ();
204
+ $ books [1 ]->fill (['name ' => 'Book ac ' ])->save ();
205
+ $ books [2 ]->fill (['name ' => 'Book AD ' ])->save ();
206
+
207
+ // Set book ordering
208
+ $ this ->asAdmin ()->put ($ shelf ->getUrl (), [
209
+ 'books ' => $ books ->implode ('id ' , ', ' ),
210
+ 'tags ' => [], 'description ' => 'abc ' , 'name ' => 'abc ' ,
211
+ ]);
212
+ $ this ->assertEquals (3 , $ shelf ->books ()->count ());
213
+ $ shelf ->refresh ();
214
+
215
+ setting ()->putUser ($ this ->users ->editor (), 'shelf_books_sort ' , 'name ' );
216
+ setting ()->putUser ($ this ->users ->editor (), 'shelf_books_sort_order ' , 'asc ' );
217
+ $ html = $ this ->withHtml ($ this ->asEditor ()->get ($ shelf ->getUrl ()));
218
+
219
+ $ html ->assertElementContains ('.book-content a.grid-card:nth-child(1) ' , 'Book Ab ' );
220
+ $ html ->assertElementContains ('.book-content a.grid-card:nth-child(2) ' , 'Book ac ' );
221
+ $ html ->assertElementContains ('.book-content a.grid-card:nth-child(3) ' , 'Book AD ' );
222
+ }
223
+
199
224
public function test_shelf_edit ()
200
225
{
201
226
$ shelf = $ this ->entities ->shelf ();
0 commit comments