@@ -19,10 +19,81 @@ public function testNoFiles()
1919 public function testDefaultDisplaysCards ()
2020 {
2121 $ file = fake (FileFaker::class);
22-
22+
2323 $ result = $ this ->get ('files ' );
2424
2525 $ result ->assertStatus (200 );
2626 $ result ->assertSee ($ file ->filename );
2727 }
28+
29+ public function provideSort ()
30+ {
31+ yield ['filename ' , 'filename ' ];
32+ yield ['localname ' , 'localname ' ];
33+ yield ['clientname ' , 'clientname ' ];
34+ yield ['type ' , 'type ' ];
35+ yield ['size ' , 'size ' ];
36+ yield ['thumbnail ' , 'thumbnail ' ];
37+ yield ['invalidsort ' , 'filename ' ];
38+ }
39+
40+ /**
41+ * @dataProvider provideSort
42+ */
43+ public function testSorts (string $ sort , string $ configSort )
44+ {
45+ $ _REQUEST ['sort ' ] = $ sort ;
46+
47+ $ file = fake (FileFaker::class);
48+ $ result = $ this ->get ('files ' );
49+
50+ $ result ->assertStatus (200 );
51+ $ this ->assertEquals ($ configSort , service ('settings ' )->filesSort );
52+ }
53+
54+ public function provideOrder ()
55+ {
56+ yield ['asc ' , 'asc ' ];
57+ yield ['desc ' , 'desc ' ];
58+ yield ['invalid ' , 'asc ' ];
59+ }
60+
61+ /**
62+ * @dataProvider provideOrder
63+ */
64+ public function testOrders (string $ order , string $ configOrder )
65+ {
66+ $ _REQUEST ['order ' ] = $ order ;
67+
68+ $ file = fake (FileFaker::class);
69+ $ result = $ this ->get ('files ' );
70+
71+ $ result ->assertStatus (200 );
72+ $ this ->assertEquals ($ configOrder , service ('settings ' )->filesOrder );
73+ }
74+
75+ public function provideSearch ()
76+ {
77+ yield ['Heathcote ' ];
78+ }
79+
80+ /**
81+ * @dataProvider provideSearch
82+ */
83+ public function testSearches (string $ keyword )
84+ {
85+ $ _REQUEST ['search ' ] = $ keyword ;
86+
87+ $ file = fake (FileFaker::class);
88+ $ result = $ this ->get ('files ' );
89+
90+ $ result ->assertStatus (200 );
91+ $ content = $ result ->response ->getBody ();
92+
93+ if (strpos ($ content , $ keyword ) !== false ) {
94+ $ result ->assertSee ($ keyword );
95+ } else {
96+ $ result ->assertSee ('You have no files! ' );
97+ }
98+ }
2899}
0 commit comments