-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix exception when domain name is not given
- Loading branch information
Alexander Gaal
committed
Jan 22, 2024
1 parent
ba3075b
commit 64341b7
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use AkrilliA\LaravelBeyond\Commands\MakeEnumCommand; | ||
use AkrilliA\LaravelBeyond\NameResolver; | ||
|
||
class NameResolverTest extends TestCase | ||
{ | ||
public function testCanResolveAppOrDomainName(): void | ||
{ | ||
$resolver = new NameResolver( | ||
command: new MakeEnumCommand, | ||
name: 'Users.UserStatusEnum', | ||
); | ||
|
||
$this->assertSame('Users', $resolver->getAppOrDomain()); | ||
} | ||
|
||
public function testCanResolveClassName(): void | ||
{ | ||
$resolver = new NameResolver( | ||
command: new MakeEnumCommand, | ||
name: 'Users.UserStatusEnum', | ||
); | ||
|
||
$this->assertSame('UserStatusEnum', $resolver->getClassName()); | ||
} | ||
|
||
public function testCanResolveNamespace(): void | ||
{ | ||
$resolver = new NameResolver( | ||
command: new MakeEnumCommand, | ||
name: 'Users.UserStatusEnum', | ||
); | ||
|
||
$this->assertSame('Domain\\Users\\Enums', $resolver->getNamespace()); | ||
} | ||
|
||
public function testCanResolveAppOrDomainByQuestion(): void | ||
{ | ||
$this->artisan(MakeEnumCommand::class, [ | ||
'name' => 'Users/UserStatusEnum' | ||
]) | ||
->expectsQuestion('On which domain do you want to add your Enum', 'Users') | ||
->assertSuccessful(); | ||
} | ||
} |