@@ -41,6 +41,8 @@ protected function setUp(): void
4141 command ('logs:clear --force ' );
4242 $ this ->resetStreamFilterBuffer ();
4343
44+ CLI ::reset ();
45+
4446 $ this ->createDummyLogFiles ();
4547 }
4648
@@ -78,7 +80,7 @@ public function testClearLogsUsingForce(): void
7880
7981 $ this ->assertFileDoesNotExist (WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . "log- {$ this ->date }.log " );
8082 $ this ->assertFileExists (WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . 'index.html ' );
81- $ this ->assertSame ("Logs cleared. \n" , preg_replace ('/\e\[[^m]+m/ ' , '' , $ this ->getStreamFilterBuffer ()));
83+ $ this ->assertSame ("\n Logs cleared. \n" , preg_replace ('/\e\[[^m]+m/ ' , '' , $ this ->getStreamFilterBuffer ()));
8284 }
8385
8486 public function testClearLogsAbortsClearWithoutForce (): void
@@ -94,11 +96,12 @@ public function testClearLogsAbortsClearWithoutForce(): void
9496 $ this ->assertFileExists (WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . "log- {$ this ->date }.log " );
9597 $ this ->assertSame (
9698 <<<'EOT'
99+ Are you sure you want to delete the logs? [n, y]: n
97100 Deleting logs aborted.
98101 If you want, use the "--force" option to force delete all log files.
99102
100103 EOT,
101- preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput (2 ) . $ io -> getOutput ( 3 )),
104+ preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput ()),
102105 );
103106 }
104107
@@ -110,16 +113,19 @@ public function testClearLogsAbortsClearWithoutForceWithDefaultAnswer(): void
110113 $ io ->setInputs (['' ]);
111114 CLI ::setInputOutput ($ io );
112115
116+ $ space = ' ' ;
117+
113118 command ('logs:clear ' );
114119
115120 $ this ->assertFileExists (WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . "log- {$ this ->date }.log " );
116121 $ this ->assertSame (
117- <<<'EOT'
122+ <<<EOT
123+ Are you sure you want to delete the logs? [n, y]: {$ space }
118124 Deleting logs aborted.
119125 If you want, use the "--force" option to force delete all log files.
120126
121127 EOT ,
122- preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput (2 ) . $ io -> getOutput ( 3 )),
128+ preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput ()),
123129 );
124130 }
125131
@@ -134,7 +140,13 @@ public function testClearLogsWithoutForceButWithConfirmation(): void
134140 command ('logs:clear ' );
135141
136142 $ this ->assertFileDoesNotExist (WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . "log- {$ this ->date }.log " );
137- $ this ->assertSame ("Logs cleared. \n" , preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput (2 )));
143+ $ this ->assertSame (
144+ <<<EOT
145+ Are you sure you want to delete the logs? [n, y]: y
146+ Logs cleared.
147+
148+ EOT ,
149+ preg_replace ('/\e\[[^m]+m/ ' , '' , $ io ->getOutput ()));
138150 }
139151
140152 #[RequiresOperatingSystem('Darwin|Linux ' )]
@@ -173,6 +185,9 @@ public function testClearLogsFailsOnChmodFailure(): void
173185 }
174186
175187 $ this ->assertFileExists ($ path );
176- $ this ->assertSame ("Error in deleting the logs files. \n" , preg_replace ('/\e\[[^m]+m/ ' , '' , $ this ->getStreamFilterBuffer ()));
188+ $ this ->assertSame (
189+ "\nError in deleting the logs files. \n" ,
190+ preg_replace ('/\e\[[^m]+m/ ' , '' , $ this ->getStreamFilterBuffer ()),
191+ );
177192 }
178193}
0 commit comments