Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 19, 2024
1 parent 4481795 commit 33ecb20
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/sync
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ transform([
transform([
'namespace Database\Seeders;' => 'namespace Workbench\Database\Seeders;',
'use App\Models\User;' => 'use Orchestra\Testbench\Factories\UserFactory;',
'User::factory(10)->create' => 'UserFactory::new->times(10)->create',
'User::factory(10)->create' => 'UserFactory::new()->times(10)->create',
'User::factory()->create' => 'UserFactory::new()->create',
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/src/Console/stubs/database/seeders/DatabaseSeeder.php"));

Expand Down
2 changes: 1 addition & 1 deletion src/Console/stubs/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// UserFactory::new->times(10)->create();
// UserFactory::new()->times(10)->create();

UserFactory::new()->create([
'name' => 'Test User',
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/CommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function assertCommandExecutedWithDevTool(bool $prefix = true): void
\sprintf('use %sFactories\UserFactory;', $prefix ? 'Workbench\Database\\' : 'Database\\'),
'class DatabaseSeeder extends Seeder',
'// UserFactory::new()->times(10)->create();',
'// UserFactory::new()->create([',
'UserFactory::new()->create([',
], join_paths($workingPath, 'workbench', 'database', 'seeders', 'DatabaseSeeder.php'));
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Console/DevToolCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DevToolCommandTest extends CommandTestCase
public function it_can_run_devtool_command_with_installation(?string $answer, bool $createEnvironmentFile)
{
$this->artisan('workbench:devtool', ['--install' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->expectsChoice("Export '.env' file as?", $answer, [
'Skip exporting .env',
'.env',
Expand All @@ -33,7 +33,7 @@ public function it_can_run_devtool_command_with_installation(?string $answer, bo
public function it_can_run_devtool_command_with_basic_installation(?string $answer, bool $createEnvironmentFile)
{
$this->artisan('workbench:devtool', ['--install' => true, '--basic' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->expectsChoice("Export '.env' file as?", $answer, [
'Skip exporting .env',
'.env',
Expand All @@ -53,7 +53,7 @@ public function it_can_run_devtool_command_with_basic_installation(?string $answ
public function it_can_run_devtool_command_without_installation()
{
$this->artisan('workbench:devtool', ['--no-install' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->assertSuccessful();

$this->assertCommandExecutedWithDevTool();
Expand All @@ -64,7 +64,7 @@ public function it_can_run_devtool_command_without_installation()
public function it_can_be_installed_with_no_interaction_options()
{
$this->artisan('workbench:devtool', ['--no-install' => true, '--no-interaction' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->assertSuccessful();

$this->assertCommandExecutedWithDevTool();
Expand All @@ -76,7 +76,7 @@ public function it_can_be_installed_with_prompt_for_missing_arguments()
{
$this->artisan('workbench:devtool')
->expectsConfirmation('Run Workbench installation?', false)
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->assertSuccessful();

$this->assertCommandExecutedWithDevTool();
Expand Down
9 changes: 6 additions & 3 deletions tests/Console/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class InstallCommandTest extends CommandTestCase
public function it_can_run_installation_command_with_devtool(?string $answer, bool $createEnvironmentFile)
{
$this->artisan('workbench:install', ['--devtool' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'yes')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'yes')
->expectsChoice("Export '.env' file as?", $answer, [
'Skip exporting .env',
'.env',
Expand All @@ -37,13 +37,16 @@ public function it_can_run_installation_command_with_devtool(?string $answer, bo
public function it_can_run_installation_command_with_devtool_without_workbench_prefix(?string $answer, bool $createEnvironmentFile)
{
$this->artisan('workbench:install', ['--devtool' => true])
->expectsConfirmation('Prefix with `Workbench` namespace?', 'no')
->expectsConfirmation('Prefix with `Workbench` namespace?', answer: 'no')
->expectsChoice("Export '.env' file as?", $answer, [
'Skip exporting .env',
'.env',
'.env.example',
'.env.dist',
])->assertSuccessful();
])
->expectsConfirmation('Generate `workbench/bootstrap/app.php` file?', answer: 'no')
->expectsConfirmation('Generate `workbench/bootstrap/providers.php` file?', answer: 'no')
->assertSuccessful();

$this->assertCommandExecutedWithInstall(prefix: false);
$this->assertCommandExecutedWithDevTool(prefix: false);
Expand Down

0 comments on commit 33ecb20

Please sign in to comment.