Skip to content

Commit 1a2bd93

Browse files
committed
refactor: edit for integration.
1 parent c9d1783 commit 1a2bd93

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

src/Commands/Setup.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ private function publishConfig(): void
8787
$this->setupHelper();
8888
$this->setupRoutes();
8989

90-
$this->runMigrations();
91-
9290
$this->setSecurityCSRF();
91+
92+
$this->runMigrations();
9393
}
9494

9595
/**
@@ -260,18 +260,6 @@ private function setupRoutes(): void
260260
$this->add($file, $check, $pattern, $replace);
261261
}
262262

263-
private function runMigrations(): void
264-
{
265-
if (
266-
$this->cliPrompt(' Run `spark migrate --all` now?', ['y', 'n']) === 'n'
267-
) {
268-
return;
269-
}
270-
271-
$command = new Migrate(Services::logger(), Services::commands());
272-
$command->run(['all' => null]);
273-
}
274-
275263
/**
276264
* @see https://github.com/codeigniter4/shield/security/advisories/GHSA-5hm8-vh6r-2cjq
277265
*/
@@ -302,12 +290,24 @@ private function setSecurityCSRF(): void
302290
}
303291

304292
if (write_file($path, $output)) {
305-
CLI::write(CLI::color(' Update: ', 'green') . "We have updated file '{$cleanPath}' for security reasons.");
293+
CLI::write(CLI::color(' Updated: ', 'green') . "We have updated file '{$cleanPath}' for security reasons.");
306294
} else {
307295
CLI::error(" Error updating file '{$cleanPath}'.");
308296
}
309297
}
310298

299+
private function runMigrations(): void
300+
{
301+
if (
302+
$this->cliPrompt(' Run `spark migrate --all` now?', ['y', 'n']) === 'n'
303+
) {
304+
return;
305+
}
306+
307+
$command = new Migrate(Services::logger(), Services::commands());
308+
$command->run(['all' => null]);
309+
}
310+
311311
/**
312312
* This method is for testing.
313313
*/

tests/Commands/SetupTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,13 @@ public function testRun(): void
6969
' Created: vfs://root/Config/Auth.php
7070
Created: vfs://root/Config/AuthGroups.php
7171
Updated: vfs://root/Controllers/BaseController.php
72-
Updated: vfs://root/Config/Routes.php',
72+
Updated: vfs://root/Config/Routes.php
73+
Updated: We have updated file \'vfs://root/Config/Security.php\' for security reasons.',
7374
$result
7475
);
7576
$this->assertStringContainsString(
7677
'Running all new migrations...',
7778
$result
7879
);
79-
80-
$this->assertStringContainsString(
81-
'Update: We have updated file \'vfs://root/Config/Security.php\' for security reasons.',
82-
$result
83-
);
8480
}
8581
}

0 commit comments

Comments
 (0)