@@ -20,29 +20,7 @@ protected function setUp(): void
2020
2121 CITestStreamFilter::$ buffer = '' ;
2222 $ this ->streamFilter = stream_filter_append (STDOUT , 'CITestStreamFilter ' );
23-
24- $ this ->env = new \CodeIgniter \Config \DotEnv (ROOTPATH );
25- $ this ->env ->load ();
26-
27- // Set environment values that would otherwise stop the framework from functioning during tests.
28- if (! isset ($ _SERVER ['app.baseURL ' ]))
29- {
30- $ _SERVER ['app.baseURL ' ] = 'http://example.com ' ;
31- }
32-
33- $ _SERVER ['argv ' ] = [
34- 'spark ' ,
35- 'list ' ,
36- ];
37- $ _SERVER ['argc ' ] = 2 ;
38- CLI ::init ();
39-
40- $ this ->config = new MockAppConfig ();
41- $ this ->request = new \CodeIgniter \HTTP \IncomingRequest ($ this ->config , new \CodeIgniter \HTTP \URI ('https://somwhere.com ' ), null , new UserAgent ());
42- $ this ->response = new \CodeIgniter \HTTP \Response ($ this ->config );
43- $ this ->logger = Services::logger ();
44- $ this ->runner = new CommandRunner ();
45- $ this ->runner ->initController ($ this ->request , $ this ->response , $ this ->logger );
23+ $ this ->streamFilter = stream_filter_append (STDERR , 'CITestStreamFilter ' );
4624 }
4725
4826 public function tearDown (): void
@@ -57,13 +35,23 @@ public function tearDown(): void
5735
5836 public function testClearCacheInvalidHandler ()
5937 {
60- $ config = config ('Cache ' );
61- $ config ->handler = 'junk ' ;
62- Config::injectMock ('Cache ' , $ config );
63-
64- $ this ->runner ->index (['cache:clear ' ]);
38+ command ('cache:clear junk ' );
6539 $ result = CITestStreamFilter::$ buffer ;
6640
6741 $ this ->assertStringContainsString ('junk is not a valid cache handler. ' , $ result );
6842 }
43+
44+ public function testClearCacheWorks ()
45+ {
46+ cache ()->save ('foo ' , 'bar ' );
47+
48+ $ this ->assertEquals ('bar ' , cache ('foo ' ));
49+
50+ command ('cache:clear ' );
51+ $ result = CITestStreamFilter::$ buffer ;
52+
53+ $ this ->assertNull (cache ('foo ' ));
54+
55+ $ this ->assertStringContainsString ('Done ' , $ result );
56+ }
6957}
0 commit comments