@@ -49,12 +49,7 @@ public function testRun(): void
4949 'y ' ,
5050 ]);
5151
52- $ root = vfsStream::setup ('root ' );
53- vfsStream::copyFromFileSystem (
54- APPPATH ,
55- $ root
56- );
57- $ appFolder = $ root ->url () . '/ ' ;
52+ $ appFolder = $ this ->createFilesystem ();
5853
5954 $ command = new Setup (Services::logger (), Services::commands ());
6055
@@ -76,7 +71,7 @@ public function testRun(): void
7671 $ security = file_get_contents ($ appFolder . 'Config/Security.php ' );
7772 $ this ->assertStringContainsString ('$csrfProtection = \'session \'; ' , $ security );
7873
79- $ result = str_replace ([ "\033 [0;32m " , "\033 [0m " ], '' , $ this ->io -> getOutputs () );
74+ $ result = $ this ->getOutputWithoutColorCode ( );
8075
8176 $ this ->assertStringContainsString (
8277 ' Created: vfs://root/Config/Auth.php
@@ -103,20 +98,15 @@ public function testRunEmailConfigIsFine(): void
10398 $ config->
fromEmail =
'[email protected] ' ;
10499 $ config ->fromName = 'Site Admin ' ;
105100
106- $ root = vfsStream::setup ('root ' );
107- vfsStream::copyFromFileSystem (
108- APPPATH ,
109- $ root
110- );
111- $ appFolder = $ root ->url () . '/ ' ;
101+ $ appFolder = $ this ->createFilesystem ();
112102
113103 $ command = new Setup (Services::logger (), Services::commands ());
114104
115105 $ this ->setPrivateProperty ($ command , 'distPath ' , $ appFolder );
116106
117107 $ command ->run ([]);
118108
119- $ result = str_replace ([ "\033 [0;32m " , "\033 [0m " ], '' , $ this ->io -> getOutputs () );
109+ $ result = $ this ->getOutputWithoutColorCode ( );
120110
121111 $ this ->assertStringContainsString (
122112 ' Created: vfs://root/Config/Auth.php
@@ -128,4 +118,23 @@ public function testRunEmailConfigIsFine(): void
128118 $ result
129119 );
130120 }
121+
122+ /**
123+ * @return string app folder path
124+ */
125+ private function createFilesystem (): string
126+ {
127+ $ root = vfsStream::setup ('root ' );
128+ vfsStream::copyFromFileSystem (
129+ APPPATH ,
130+ $ root
131+ );
132+
133+ return $ root ->url () . '/ ' ;
134+ }
135+
136+ private function getOutputWithoutColorCode (): string
137+ {
138+ return str_replace (["\033[0;32m " , "\033[0m " ], '' , $ this ->io ->getOutputs ());
139+ }
131140}
0 commit comments