Skip to content

Commit

Permalink
test: remove old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
regnerisch committed May 21, 2024
1 parent 0efae17 commit 82f9bfd
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 194 deletions.
31 changes: 1 addition & 30 deletions src/Commands/MakeModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class MakeModelCommand extends DomainCommand
{
protected $signature = 'beyond:make:model {name} {--f|factory} {--m|migration} {--force}';
protected $signature = 'beyond:make:model {name} {--force}';

protected $description = 'Make a new model';

Expand All @@ -22,33 +22,4 @@ public function getType(): Type
{
return new Type('Model');
}

public function setup(NameResolver $nameResolver): void
{
if ($this->option('migration')) {
$command = new MakeMigrationCommand();
$fqn = $command->getNameResolver($nameResolver->getAppOrDomain().'.create_fake_table');

$this->addOnSuccess(function (string $namespace, string $className) use ($fqn) {
$this->call(MakeMigrationCommand::class, [
'name' => $fqn->getAppOrDomain().'.create_'.Str::of($className)->pluralStudly()->lower().'_table',
]);
});

// Add MakeFactoryCommand!
// if ($this->option('factory')) {
// $fileName = $className.'Factory';
//
// beyond_copy_stub(
// 'factory.stub',
// base_path()."/modules/$module/Infrastructure/factories/$fileName.php",
// [
// '{{ namespace }}' => $namespace,
// '{{ model }}' => $fileName,
// ],
// $force
// );
// }
}
}
}
36 changes: 0 additions & 36 deletions tests/Commands/MakeMiddlewareCommandTest.php

This file was deleted.

92 changes: 0 additions & 92 deletions tests/Commands/MakeModelCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,96 +33,4 @@ public function testCanMakeModelUsingForce(): void

$code->assertOk();
}

public function testCanMakeModelWithFactory(): void
{
$this->markTestSkipped('Not implemented yet!');

/* @phpstan-ignore-next-line */
$this->artisan('beyond:make:model User.User --factory');

$file = beyond_domain_path('User/Models/User.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ className }}', $contents);

$file = beyond_infra_path('User/Infrastructure/Factories/UserFactory.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ model }}', $contents);
}

public function testCanMakeModelWithFactoryUsingForce(): void
{
$this->markTestSkipped('Not implemented yet!');

/* @phpstan-ignore-next-line */
$this->artisan('beyond:make:model User.User --factory');

$file = beyond_domain_path('User/Models/User.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ className }}', $contents);

$file = beyond_infra_path('User/Factories/UserFactory.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ model }}', $contents);

$code = $this->artisan('beyond:make:model User.User --factory --force');

$code->assertOk();
}

public function testCanMakeModelWithMigration(): void
{
$this->artisan('beyond:make:model User.User --migration');

$now = new \DateTime();

$file = beyond_domain_path('User/Models/User.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ className }}', $contents);

$file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_create_users_table.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringContainsString('Schema::create', $contents);
}

public function testCanMakeModelWithMigrationUsingForce(): void
{
$this->artisan('beyond:make:model User.User --migration');

$now = new \DateTime();

$file = beyond_domain_path('User/Models/User.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringNotContainsString('{{ namespace }}', $contents);
$this->assertStringNotContainsString('{{ className }}', $contents);

$file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_create_users_table.php');
$contents = file_get_contents($file);

$this->assertFileExists($file);
$this->assertStringContainsString('Schema::create', $contents);

$code = $this->artisan('beyond:make:model User.User --migration --force');

$code->assertOk();
}
}
36 changes: 0 additions & 36 deletions tests/Commands/MakeNotificationCommandTest.php

This file was deleted.

0 comments on commit 82f9bfd

Please sign in to comment.