@@ -26,6 +26,41 @@ public function testDefaultDisplaysCards()
2626 $ result ->assertSee ($ file ->filename );
2727 }
2828
29+ public function testDataUsesSettings ()
30+ {
31+ service ('settings ' )->filesSort = 'type ' ;
32+ service ('settings ' )->filesOrder = 'asc ' ;
33+ service ('settings ' )->filesFormat = 'cards ' ;
34+
35+ $ file = fake (FileFaker::class);
36+ $ result = $ this ->get ('files ' );
37+ $ result ->assertStatus (200 );
38+ $ result ->assertSee ($ file ->filename );
39+ }
40+
41+ public function provideFormat ()
42+ {
43+ yield ['cards ' , 'cards ' ];
44+ yield ['list ' , 'list ' ];
45+ yield ['select ' , 'select ' ];
46+ yield ['invalid ' , config ('Files ' )->defaultFormat ];
47+ }
48+
49+ /**
50+ * @dataProvider provideFormat
51+ */
52+
53+ public function testFormat (string $ format , string $ configFormat )
54+ {
55+ $ _REQUEST ['format ' ] = $ format ;
56+
57+ $ file = fake (FileFaker::class);
58+ $ result = $ this ->get ('files ' );
59+
60+ $ result ->assertStatus (200 );
61+ $ this ->assertEquals ($ configFormat , service ('settings ' )->filesFormat );
62+ }
63+
2964 public function provideSort ()
3065 {
3166 yield ['filename ' , 'filename ' ];
@@ -75,6 +110,7 @@ public function testOrders(string $order, string $configOrder)
75110 public function provideSearch ()
76111 {
77112 yield ['Heathcote ' ];
113+ yield ['will never be found ' ];
78114 }
79115
80116 /**
@@ -90,9 +126,12 @@ public function testSearches(string $keyword)
90126 $ result ->assertStatus (200 );
91127 $ content = $ result ->response ->getBody ();
92128
93- if (strpos ($ content , $ keyword ) !== false ) {
129+ if (strpos ($ content , $ keyword ) !== false )
130+ {
94131 $ result ->assertSee ($ keyword );
95- } else {
132+ }
133+ else
134+ {
96135 $ result ->assertSee ('You have no files! ' );
97136 }
98137 }
0 commit comments