Skip to content

Commit 7630b1c

Browse files
committed
refactor: replace custom ArrayFile with laravel-config-writer version
Refs: #67
1 parent ea9e242 commit 7630b1c

File tree

4 files changed

+33
-145
lines changed

4 files changed

+33
-145
lines changed

src/Commands/InitCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use RonasIT\ProjectInitializator\Enums\AppTypeEnum;
1313
use RonasIT\ProjectInitializator\Enums\AuthTypeEnum;
1414
use RonasIT\ProjectInitializator\Enums\RoleEnum;
15-
use RonasIT\ProjectInitializator\Extensions\ConfigWriter\ArrayFile;
15+
use Winter\LaravelConfigWriter\ArrayFile;
1616
use Winter\LaravelConfigWriter\EnvFile;
1717

1818
class InitCommand extends Command implements Isolatable

src/Extensions/ConfigWriter/ArrayFile.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Extensions/ConfigWriter/ArrayPrinter.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/InitCommandTest.php

Lines changed: 32 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ class InitCommandTest extends TestCase
1010

1111
public function testRunWithoutAdminAndReadmeCreationConvertAppNameToPascalCaseTelescopeAlreadyInstalled()
1212
{
13-
$this->mockNativeFunction(
14-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
15-
$this->callFileExists(base_path('config/telescope.php')),
16-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
17-
$this->callFileExists(base_path('config/auto-doc.php')),
18-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
19-
);
20-
2113
$this->mockNativeFunction(
2214
'\Winter\LaravelConfigWriter',
2315
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_pascal_case.yml'),
2416
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_pascal_case.yml'),
2517
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
2618
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
19+
$this->callFileExists(base_path('config/telescope.php')),
20+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
21+
$this->callFileExists(base_path('config/auto-doc.php')),
22+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
2723
);
2824

2925
$this->mockNativeFunction(
@@ -72,20 +68,16 @@ public function testRunWithoutAdminAndReadmeCreationConvertAppNameToPascalCaseTe
7268

7369
public function testRunWithoutAdminAndReadmeCreation()
7470
{
75-
$this->mockNativeFunction(
76-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
77-
$this->callFileExists(base_path('config/telescope.php')),
78-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
79-
$this->callFileExists(base_path('config/auto-doc.php')),
80-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
81-
);
82-
8371
$this->mockNativeFunction(
8472
'\Winter\LaravelConfigWriter',
8573
$this->changeEnvFileCall('.env', 'env.example.yml', 'env.example_app_name_pascal_case.yml'),
8674
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_pascal_case.yml'),
8775
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
8876
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
77+
$this->callFileExists(base_path('config/telescope.php')),
78+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
79+
$this->callFileExists(base_path('config/auto-doc.php')),
80+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
8981
);
9082

9183
$this->mockNativeFunction(
@@ -133,20 +125,16 @@ public function testRunWithoutAdminAndReadmeCreation()
133125

134126
public function testRunWithAdminAndWithoutReadmeCreation()
135127
{
136-
$this->mockNativeFunction(
137-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
138-
$this->callFileExists(base_path('config/telescope.php')),
139-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
140-
$this->callFileExists(base_path('config/auto-doc.php')),
141-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
142-
);
143-
144128
$this->mockNativeFunction(
145129
'\Winter\LaravelConfigWriter',
146130
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
147131
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
148132
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
149133
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
134+
$this->callFileExists(base_path('config/telescope.php')),
135+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
136+
$this->callFileExists(base_path('config/auto-doc.php')),
137+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
150138
);
151139

152140
$this->mockNativeFunction(
@@ -198,14 +186,6 @@ public function testRunWithAdminAndWithoutReadmeCreation()
198186

199187
public function testRunWithAdminAndDefaultReadmeCreation()
200188
{
201-
$this->mockNativeFunction(
202-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
203-
$this->callFileExists(base_path('config/telescope.php')),
204-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
205-
$this->callFileExists(base_path('config/auto-doc.php')),
206-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
207-
);
208-
209189
$this->mockNativeFunction(
210190
'\Winter\LaravelConfigWriter',
211191
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
@@ -214,6 +194,10 @@ public function testRunWithAdminAndDefaultReadmeCreation()
214194
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added.yml'),
215195
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
216196
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
197+
$this->callFileExists(base_path('config/telescope.php')),
198+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
199+
$this->callFileExists(base_path('config/auto-doc.php')),
200+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
217201
);
218202

219203
$this->mockNativeFunction(
@@ -333,20 +317,16 @@ public function testRunWithAdminAndDefaultReadmeCreation()
333317

334318
public function testRunWithAdminAndPartialReadmeCreation()
335319
{
336-
$this->mockNativeFunction(
337-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
338-
$this->callFileExists(base_path('config/telescope.php')),
339-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
340-
$this->callFileExists(base_path('config/auto-doc.php')),
341-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
342-
);
343-
344320
$this->mockNativeFunction(
345321
'\Winter\LaravelConfigWriter',
346322
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
347323
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
348324
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
349325
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
326+
$this->callFileExists(base_path('config/telescope.php')),
327+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
328+
$this->callFileExists(base_path('config/auto-doc.php')),
329+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
350330
);
351331

352332
$this->mockNativeFunction(
@@ -444,20 +424,16 @@ public function testRunWithAdminAndPartialReadmeCreation()
444424

445425
public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializatorInstallationMedia()
446426
{
447-
$this->mockNativeFunction(
448-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
449-
$this->callFileExists(base_path('config/telescope.php')),
450-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
451-
$this->callFileExists(base_path('config/auto-doc.php')),
452-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
453-
);
454-
455427
$this->mockNativeFunction(
456428
'\Winter\LaravelConfigWriter',
457429
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
458430
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
459431
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
460432
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
433+
$this->callFileExists(base_path('config/telescope.php')),
434+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
435+
$this->callFileExists(base_path('config/auto-doc.php')),
436+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
461437
);
462438

463439
$this->mockNativeFunction(
@@ -571,20 +547,16 @@ public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializatorIns
571547

572548
public function testRunWithoutAdminAndUsingTelescope()
573549
{
574-
$this->mockNativeFunction(
575-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
576-
$this->callFileExists(base_path('config/telescope.php')),
577-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
578-
$this->callFileExists(base_path('config/auto-doc.php')),
579-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
580-
);
581-
582550
$this->mockNativeFunction(
583551
'\Winter\LaravelConfigWriter',
584552
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
585553
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
586554
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
587555
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
556+
$this->callFileExists(base_path('config/telescope.php')),
557+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
558+
$this->callFileExists(base_path('config/auto-doc.php')),
559+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
588560
);
589561

590562
$this->mockNativeFunction(
@@ -686,14 +658,6 @@ public function testRunWithoutAdminAndUsingTelescope()
686658

687659
public function testRunWithClerkMobileAppWithPintInstalled(): void
688660
{
689-
$this->mockNativeFunction(
690-
'\RonasIT\ProjectInitializator\Extensions\ConfigWriter',
691-
$this->callFileExists(base_path('config/telescope.php')),
692-
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
693-
$this->callFileExists(base_path('config/auto-doc.php')),
694-
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
695-
);
696-
697661
$this->mockNativeFunction(
698662
'\Winter\LaravelConfigWriter',
699663
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
@@ -702,6 +666,10 @@ public function testRunWithClerkMobileAppWithPintInstalled(): void
702666
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added_mobile_app.yml'),
703667
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
704668
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
669+
$this->callFileExists(base_path('config/telescope.php')),
670+
$this->callFileGetContent(base_path('config/telescope.php'), $this->getFixture('telescope_config.php')),
671+
$this->callFileExists(base_path('config/auto-doc.php')),
672+
$this->callFileGetContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc.php')),
705673
);
706674

707675
$this->mockNativeFunction(

0 commit comments

Comments
 (0)