@@ -49,7 +49,7 @@ protected function tearDown(): void
4949
5050 private function removeGeneratedFiles (): void
5151 {
52- preg_match_all ('/File (?:created|overwritten): (APPPATH[^\r\n\x1b]+)/ ' , $ this ->getStreamFilterBuffer (), $ matches );
52+ preg_match_all ('/File (?:created|overwritten): "? (APPPATH[^" \r\n\x1b]+)/ ' , $ this ->getStreamFilterBuffer (), $ matches );
5353
5454 foreach ($ matches [1 ] as $ file ) {
5555 $ path = str_replace ('APPPATH ' . DIRECTORY_SEPARATOR , APPPATH , $ file );
@@ -80,34 +80,18 @@ public function testCreateComponentProducesManyFiles(): void
8080 {
8181 command ('make:scaffold people ' );
8282
83- $ dir = '\\' . DIRECTORY_SEPARATOR ;
84- $ migration = "APPPATH {$ dir }Database {$ dir }Migrations {$ dir }(.*) \\.php " ;
85- preg_match ('/ ' . $ migration . '/u ' , $ this ->getStreamFilterBuffer (), $ matches );
86- $ matches [0 ] = str_replace ('APPPATH ' . DIRECTORY_SEPARATOR , APPPATH , $ matches [0 ]);
87-
8883 // Files check
8984 $ this ->assertStringContainsString ('File created: ' , $ this ->getStreamFilterBuffer ());
9085 $ this ->assertFileExists (APPPATH . 'Controllers/People.php ' );
9186 $ this ->assertFileExists (APPPATH . 'Models/People.php ' );
9287 $ this ->assertStringContainsString ('_People.php ' , $ this ->getStreamFilterBuffer ());
9388 $ this ->assertFileExists (APPPATH . 'Database/Seeds/People.php ' );
94-
95- // Options check
96- unlink (APPPATH . 'Controllers/People.php ' );
97- unlink (APPPATH . 'Models/People.php ' );
98- unlink ($ matches [0 ]);
99- unlink (APPPATH . 'Database/Seeds/People.php ' );
10089 }
10190
10291 public function testCreateComponentWithManyOptions (): void
10392 {
10493 command ('make:scaffold user -restful -return entity ' );
10594
106- $ dir = '\\' . DIRECTORY_SEPARATOR ;
107- $ migration = "APPPATH {$ dir }Database {$ dir }Migrations {$ dir }(.*) \\.php " ;
108- preg_match ('/ ' . $ migration . '/u ' , $ this ->getStreamFilterBuffer (), $ matches );
109- $ matches [0 ] = str_replace ('APPPATH ' . DIRECTORY_SEPARATOR , APPPATH , $ matches [0 ]);
110-
11195 // Files check
11296 $ this ->assertStringContainsString ('File created: ' , $ this ->getStreamFilterBuffer ());
11397 $ this ->assertFileExists (APPPATH . 'Controllers/User.php ' );
@@ -118,37 +102,18 @@ public function testCreateComponentWithManyOptions(): void
118102
119103 // Options check
120104 $ this ->assertStringContainsString ('extends ResourceController ' , $ this ->getFileContents (APPPATH . 'Controllers/User.php ' ));
121-
122- // Clean up
123- unlink (APPPATH . 'Controllers/User.php ' );
124- unlink ($ matches [0 ]);
125- unlink (APPPATH . 'Database/Seeds/User.php ' );
126- unlink (APPPATH . 'Entities/User.php ' );
127- rmdir (APPPATH . 'Entities ' );
128- unlink (APPPATH . 'Models/User.php ' );
129105 }
130106
131107 public function testCreateComponentWithOptionSuffix (): void
132108 {
133109 command ('make:scaffold order -suffix ' );
134110
135- $ dir = '\\' . DIRECTORY_SEPARATOR ;
136- $ migration = "APPPATH {$ dir }Database {$ dir }Migrations {$ dir }(.*) \\.php " ;
137- preg_match ('/ ' . $ migration . '/u ' , $ this ->getStreamFilterBuffer (), $ matches );
138- $ matches [0 ] = str_replace ('APPPATH ' . DIRECTORY_SEPARATOR , APPPATH , $ matches [0 ]);
139-
140111 // Files check
141112 $ this ->assertStringContainsString ('File created: ' , $ this ->getStreamFilterBuffer ());
142113 $ this ->assertFileExists (APPPATH . 'Controllers/OrderController.php ' );
143114 $ this ->assertStringContainsString ('_OrderMigration.php ' , $ this ->getStreamFilterBuffer ());
144115 $ this ->assertFileExists (APPPATH . 'Database/Seeds/OrderSeeder.php ' );
145116 $ this ->assertFileExists (APPPATH . 'Models/OrderModel.php ' );
146-
147- // Clean up
148- unlink (APPPATH . 'Controllers/OrderController.php ' );
149- unlink ($ matches [0 ]);
150- unlink (APPPATH . 'Database/Seeds/OrderSeeder.php ' );
151- unlink (APPPATH . 'Models/OrderModel.php ' );
152117 }
153118
154119 public function testCreateComponentWithOptionForce (): void
@@ -161,11 +126,6 @@ public function testCreateComponentWithOptionForce(): void
161126
162127 command ('make:scaffold fixer -bare -force ' );
163128
164- $ dir = '\\' . DIRECTORY_SEPARATOR ;
165- $ migration = "APPPATH {$ dir }Database {$ dir }Migrations {$ dir }(.*) \\.php " ;
166- preg_match ('/ ' . $ migration . '/u ' , $ this ->getStreamFilterBuffer (), $ matches );
167- $ matches [0 ] = str_replace ('APPPATH ' . DIRECTORY_SEPARATOR , APPPATH , $ matches [0 ]);
168-
169129 // Files check
170130 $ this ->assertStringContainsString ('File created: ' , $ this ->getStreamFilterBuffer ());
171131 $ this ->assertFileExists (APPPATH . 'Controllers/Fixer.php ' );
@@ -176,12 +136,6 @@ public function testCreateComponentWithOptionForce(): void
176136 // Options check
177137 $ this ->assertStringContainsString ('extends Controller ' , $ this ->getFileContents (APPPATH . 'Controllers/Fixer.php ' ));
178138 $ this ->assertStringContainsString ('File overwritten: ' , $ this ->getStreamFilterBuffer ());
179-
180- // Clean up
181- unlink (APPPATH . 'Controllers/Fixer.php ' );
182- unlink ($ matches [0 ]);
183- unlink (APPPATH . 'Database/Seeds/Fixer.php ' );
184- unlink (APPPATH . 'Models/Fixer.php ' );
185139 }
186140
187141 public function testCreateComponentWithOptionNamespace (): void
@@ -205,11 +159,5 @@ public function testCreateComponentWithOptionNamespace(): void
205159 $ this ->assertStringContainsString ('namespace App\Database\Migrations; ' , $ this ->getFileContents ($ matches [0 ]));
206160 $ this ->assertStringContainsString ('namespace App\Database\Seeds; ' , $ this ->getFileContents (APPPATH . 'Database/Seeds/Product.php ' ));
207161 $ this ->assertStringContainsString ('namespace App\Models; ' , $ this ->getFileContents (APPPATH . 'Models/Product.php ' ));
208-
209- // Clean up
210- unlink (APPPATH . 'Controllers/Product.php ' );
211- unlink ($ matches [0 ]);
212- unlink (APPPATH . 'Database/Seeds/Product.php ' );
213- unlink (APPPATH . 'Models/Product.php ' );
214162 }
215163}
0 commit comments