Skip to content

Commit a1b64db

Browse files
committed
Added config copy to Setup script
Signed-off-by: tswagger <[email protected]>
1 parent 968997a commit a1b64db

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Commands/Setup.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ private function publishConfig(): void
8383
{
8484
$this->publishConfigAuth();
8585
$this->publishConfigAuthGroups();
86+
$this->publishConfigAuthToken();
8687

8788
$this->setupHelper();
8889
$this->setupRoutes();
@@ -131,6 +132,18 @@ private function publishConfigAuthGroups(): void
131132
$this->copyAndReplace($file, $replaces);
132133
}
133134

135+
private function publishConfigAuthToken(): void
136+
{
137+
$file = 'Config/AuthToken.php';
138+
$replaces = [
139+
'namespace CodeIgniter\Shield\Config' => 'namespace Config',
140+
'use CodeIgniter\\Config\\BaseConfig;' => 'use CodeIgniter\\Shield\\Config\\AuthToken as ShieldAuthToken;',
141+
'extends BaseConfig' => 'extends ShieldAuthToken',
142+
];
143+
144+
$this->copyAndReplace($file, $replaces);
145+
}
146+
134147
/**
135148
* Write a file, catching any exceptions and showing a
136149
* nicely formatted error.

tests/Commands/SetupTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function testRun(): void
6868
$this->assertStringContainsString('namespace Config;', $auth);
6969
$this->assertStringContainsString('use CodeIgniter\Shield\Config\Auth as ShieldAuth;', $auth);
7070

71+
$authToken = file_get_contents($appFolder . 'Config/AuthToken.php');
72+
$this->assertStringContainsString('namespace Config;', $authToken);
73+
$this->assertStringContainsString('use CodeIgniter\Shield\Config\AuthToken as ShieldAuthToken;', $authToken);
74+
7175
$routes = file_get_contents($appFolder . 'Config/Routes.php');
7276
$this->assertStringContainsString('service(\'auth\')->routes($routes);', $routes);
7377

@@ -79,6 +83,7 @@ public function testRun(): void
7983
$this->assertStringContainsString(
8084
' Created: vfs://root/Config/Auth.php
8185
Created: vfs://root/Config/AuthGroups.php
86+
Created: vfs://root/Config/AuthToken.php
8287
Updated: vfs://root/Controllers/BaseController.php
8388
Updated: vfs://root/Config/Routes.php
8489
Updated: We have updated file \'vfs://root/Config/Security.php\' for security reasons.',

0 commit comments

Comments
 (0)