Skip to content

Commit 4784454

Browse files
committed
fix: remarks from revirewer
1 parent 7630b1c commit 4784454

File tree

2 files changed

+25
-48
lines changed

2 files changed

+25
-48
lines changed

tests/InitCommandTest.php

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ public function testRunWithoutAdminAndReadmeCreationConvertAppNameToPascalCaseTe
1414
'\Winter\LaravelConfigWriter',
1515
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_pascal_case.yml'),
1616
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_pascal_case.yml'),
17-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
18-
$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')),
17+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
18+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
2319
);
2420

2521
$this->mockNativeFunction(
@@ -72,12 +68,8 @@ public function testRunWithoutAdminAndReadmeCreation()
7268
'\Winter\LaravelConfigWriter',
7369
$this->changeEnvFileCall('.env', 'env.example.yml', 'env.example_app_name_pascal_case.yml'),
7470
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_pascal_case.yml'),
75-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
76-
$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')),
71+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
72+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
8173
);
8274

8375
$this->mockNativeFunction(
@@ -129,12 +121,8 @@ public function testRunWithAdminAndWithoutReadmeCreation()
129121
'\Winter\LaravelConfigWriter',
130122
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
131123
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
132-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
133-
$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')),
124+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
125+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
138126
);
139127

140128
$this->mockNativeFunction(
@@ -192,12 +180,8 @@ public function testRunWithAdminAndDefaultReadmeCreation()
192180
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
193181
$this->changeEnvFileCall('.env.development', 'env.development_app_name_not_pascal_case.yml', 'env.development_clerk_credentials_added.yml'),
194182
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added.yml'),
195-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
196-
$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')),
183+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
184+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
201185
);
202186

203187
$this->mockNativeFunction(
@@ -321,12 +305,8 @@ public function testRunWithAdminAndPartialReadmeCreation()
321305
'\Winter\LaravelConfigWriter',
322306
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
323307
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
324-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
325-
$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')),
308+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
309+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
330310
);
331311

332312
$this->mockNativeFunction(
@@ -428,12 +408,8 @@ public function testRunWithAdminAndFullReadmeCreationAndRemovingInitializatorIns
428408
'\Winter\LaravelConfigWriter',
429409
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
430410
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
431-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
432-
$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')),
411+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
412+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
437413
);
438414

439415
$this->mockNativeFunction(
@@ -551,12 +527,8 @@ public function testRunWithoutAdminAndUsingTelescope()
551527
'\Winter\LaravelConfigWriter',
552528
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
553529
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
554-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
555-
$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')),
530+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
531+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
560532
);
561533

562534
$this->mockNativeFunction(
@@ -664,12 +636,8 @@ public function testRunWithClerkMobileAppWithPintInstalled(): void
664636
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
665637
$this->changeEnvFileCall('.env.development', 'env.development_app_name_not_pascal_case.yml', 'env.development_clerk_credentials_added_mobile_app.yml'),
666638
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added_mobile_app.yml'),
667-
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
668-
$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')),
639+
$this->changeConfigFileCall('config/telescope.php', 'telescope_config.php', 'telescope_config_after_initialization.php'),
640+
$this->changeConfigFileCall('config/auto-doc.php', 'auto_doc.php', 'auto_doc_after_changes.php'),
673641
);
674642

675643
$this->mockNativeFunction(

tests/Support/Traits/InitCommandMockTrait.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ protected function changeEnvFileCall(string $fileName, string $sourceFixture, st
4646
$this->callFilePutContent($fileName, $this->getFixture($resultFixture)),
4747
];
4848
}
49+
50+
protected function changeConfigFileCall(string $fileName, string $sourceFixture, string $resultFixture): array
51+
{
52+
return [
53+
$this->callFileExists(base_path($fileName)),
54+
$this->callFileGetContent(base_path($fileName), $this->getFixture($sourceFixture)),
55+
$this->callFilePutContent(base_path($fileName), $this->getFixture($resultFixture)),
56+
];
57+
}
4958
}

0 commit comments

Comments
 (0)