v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Enums;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExtensionOwnerTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Enum 값이 올바르게 정의되어 있는지 확인합니다.
|
||||
*/
|
||||
public function test_has_correct_values(): void
|
||||
{
|
||||
$this->assertEquals('core', ExtensionOwnerType::Core->value);
|
||||
$this->assertEquals('module', ExtensionOwnerType::Module->value);
|
||||
$this->assertEquals('plugin', ExtensionOwnerType::Plugin->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* values() 메서드가 모든 값을 반환하는지 확인합니다.
|
||||
*/
|
||||
public function test_values_returns_all_values(): void
|
||||
{
|
||||
$values = ExtensionOwnerType::values();
|
||||
|
||||
$this->assertCount(3, $values);
|
||||
$this->assertContains('core', $values);
|
||||
$this->assertContains('module', $values);
|
||||
$this->assertContains('plugin', $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* isValid() 메서드가 올바르게 동작하는지 확인합니다.
|
||||
*/
|
||||
public function test_is_valid_returns_correct_result(): void
|
||||
{
|
||||
$this->assertTrue(ExtensionOwnerType::isValid('core'));
|
||||
$this->assertTrue(ExtensionOwnerType::isValid('module'));
|
||||
$this->assertTrue(ExtensionOwnerType::isValid('plugin'));
|
||||
$this->assertFalse(ExtensionOwnerType::isValid('invalid'));
|
||||
$this->assertFalse(ExtensionOwnerType::isValid(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* label() 메서드가 다국어 라벨을 반환하는지 확인합니다.
|
||||
*/
|
||||
public function test_label_returns_translated_string(): void
|
||||
{
|
||||
// label()은 __() 함수를 호출하므로 문자열을 반환해야 함
|
||||
$this->assertIsString(ExtensionOwnerType::Core->label());
|
||||
$this->assertIsString(ExtensionOwnerType::Module->label());
|
||||
$this->assertIsString(ExtensionOwnerType::Plugin->label());
|
||||
}
|
||||
|
||||
/**
|
||||
* from() 메서드로 올바르게 생성할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_can_be_created_from_string(): void
|
||||
{
|
||||
$this->assertEquals(ExtensionOwnerType::Core, ExtensionOwnerType::from('core'));
|
||||
$this->assertEquals(ExtensionOwnerType::Module, ExtensionOwnerType::from('module'));
|
||||
$this->assertEquals(ExtensionOwnerType::Plugin, ExtensionOwnerType::from('plugin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* tryFrom()이 잘못된 값에 대해 null을 반환하는지 확인합니다.
|
||||
*/
|
||||
public function test_try_from_returns_null_for_invalid_value(): void
|
||||
{
|
||||
$this->assertNull(ExtensionOwnerType::tryFrom('invalid'));
|
||||
$this->assertNull(ExtensionOwnerType::tryFrom(''));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Enums;
|
||||
|
||||
use App\Enums\MailSendStatus;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* MailSendStatus Enum 테스트
|
||||
*
|
||||
* 메일 발송 상태 Enum의 값과 동작을 검증합니다.
|
||||
*/
|
||||
class MailSendStatusTest extends TestCase
|
||||
{
|
||||
// ========================================================================
|
||||
// 케이스 값 테스트
|
||||
// ========================================================================
|
||||
|
||||
public function test_sent_case_has_correct_value(): void
|
||||
{
|
||||
$this->assertSame('sent', MailSendStatus::Sent->value);
|
||||
}
|
||||
|
||||
public function test_failed_case_has_correct_value(): void
|
||||
{
|
||||
$this->assertSame('failed', MailSendStatus::Failed->value);
|
||||
}
|
||||
|
||||
public function test_skipped_case_has_correct_value(): void
|
||||
{
|
||||
$this->assertSame('skipped', MailSendStatus::Skipped->value);
|
||||
}
|
||||
|
||||
public function test_cases_returns_all_statuses(): void
|
||||
{
|
||||
$cases = MailSendStatus::cases();
|
||||
|
||||
$this->assertCount(3, $cases);
|
||||
$this->assertContains(MailSendStatus::Sent, $cases);
|
||||
$this->assertContains(MailSendStatus::Failed, $cases);
|
||||
$this->assertContains(MailSendStatus::Skipped, $cases);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// from / tryFrom 테스트
|
||||
// ========================================================================
|
||||
|
||||
public function test_from_returns_correct_enum_for_valid_value(): void
|
||||
{
|
||||
$this->assertSame(MailSendStatus::Sent, MailSendStatus::from('sent'));
|
||||
$this->assertSame(MailSendStatus::Failed, MailSendStatus::from('failed'));
|
||||
$this->assertSame(MailSendStatus::Skipped, MailSendStatus::from('skipped'));
|
||||
}
|
||||
|
||||
public function test_from_throws_exception_for_invalid_value(): void
|
||||
{
|
||||
$this->expectException(\ValueError::class);
|
||||
|
||||
MailSendStatus::from('invalid');
|
||||
}
|
||||
|
||||
public function test_try_from_returns_null_for_invalid_value(): void
|
||||
{
|
||||
$this->assertNull(MailSendStatus::tryFrom('invalid'));
|
||||
}
|
||||
|
||||
public function test_try_from_returns_enum_for_valid_value(): void
|
||||
{
|
||||
$this->assertSame(MailSendStatus::Sent, MailSendStatus::tryFrom('sent'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Enums;
|
||||
|
||||
use App\Enums\PermissionType;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* PermissionType Enum 테스트
|
||||
*
|
||||
* 권한 타입(admin/user) Enum의 동작을 검증합니다.
|
||||
*/
|
||||
class PermissionTypeTest extends TestCase
|
||||
{
|
||||
// ========================================================================
|
||||
// 기본 Enum 동작 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* PermissionType Enum에 Admin과 User case가 존재하는지 확인
|
||||
*/
|
||||
public function test_has_admin_and_user_cases(): void
|
||||
{
|
||||
$cases = PermissionType::cases();
|
||||
|
||||
$this->assertCount(2, $cases);
|
||||
$this->assertContains(PermissionType::Admin, $cases);
|
||||
$this->assertContains(PermissionType::User, $cases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin case의 value가 'admin' 문자열인지 확인
|
||||
*/
|
||||
public function test_admin_case_has_correct_value(): void
|
||||
{
|
||||
$this->assertEquals('admin', PermissionType::Admin->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* User case의 value가 'user' 문자열인지 확인
|
||||
*/
|
||||
public function test_user_case_has_correct_value(): void
|
||||
{
|
||||
$this->assertEquals('user', PermissionType::User->value);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// values() 정적 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* values() 메서드가 모든 타입 값을 배열로 반환하는지 확인
|
||||
*/
|
||||
public function test_values_returns_all_type_values(): void
|
||||
{
|
||||
$values = PermissionType::values();
|
||||
|
||||
$this->assertIsArray($values);
|
||||
$this->assertCount(2, $values);
|
||||
$this->assertContains('admin', $values);
|
||||
$this->assertContains('user', $values);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// isValid() 정적 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* isValid()가 유효한 값에 대해 true를 반환하는지 확인
|
||||
*/
|
||||
public function test_is_valid_returns_true_for_valid_values(): void
|
||||
{
|
||||
$this->assertTrue(PermissionType::isValid('admin'));
|
||||
$this->assertTrue(PermissionType::isValid('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* isValid()가 유효하지 않은 값에 대해 false를 반환하는지 확인
|
||||
*/
|
||||
public function test_is_valid_returns_false_for_invalid_values(): void
|
||||
{
|
||||
$this->assertFalse(PermissionType::isValid('invalid'));
|
||||
$this->assertFalse(PermissionType::isValid(''));
|
||||
$this->assertFalse(PermissionType::isValid('Admin')); // 대소문자 구분
|
||||
$this->assertFalse(PermissionType::isValid('USER'));
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// label() 인스턴스 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* Admin type의 label()이 번역된 문자열을 반환하는지 확인
|
||||
*/
|
||||
public function test_admin_label_returns_translated_string(): void
|
||||
{
|
||||
$label = PermissionType::Admin->label();
|
||||
|
||||
$this->assertIsString($label);
|
||||
$this->assertNotEmpty($label);
|
||||
// 번역 키가 없는 경우 키 자체가 반환될 수 있음
|
||||
// 번역이 있는 경우 '관리자 권한' 또는 'Admin Permissions' 등
|
||||
}
|
||||
|
||||
/**
|
||||
* User type의 label()이 번역된 문자열을 반환하는지 확인
|
||||
*/
|
||||
public function test_user_label_returns_translated_string(): void
|
||||
{
|
||||
$label = PermissionType::User->label();
|
||||
|
||||
$this->assertIsString($label);
|
||||
$this->assertNotEmpty($label);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// icon() 인스턴스 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* Admin type의 icon()이 'cog'를 반환하는지 확인
|
||||
*/
|
||||
public function test_admin_icon_returns_cog(): void
|
||||
{
|
||||
$icon = PermissionType::Admin->icon();
|
||||
|
||||
$this->assertEquals('cog', $icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* User type의 icon()이 'user'를 반환하는지 확인
|
||||
*/
|
||||
public function test_user_icon_returns_user(): void
|
||||
{
|
||||
$icon = PermissionType::User->icon();
|
||||
|
||||
$this->assertEquals('user', $icon);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// from() 정적 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* from()으로 문자열에서 Enum 인스턴스 생성 가능 확인
|
||||
*/
|
||||
public function test_can_create_from_string(): void
|
||||
{
|
||||
$admin = PermissionType::from('admin');
|
||||
$user = PermissionType::from('user');
|
||||
|
||||
$this->assertInstanceOf(PermissionType::class, $admin);
|
||||
$this->assertInstanceOf(PermissionType::class, $user);
|
||||
$this->assertEquals(PermissionType::Admin, $admin);
|
||||
$this->assertEquals(PermissionType::User, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* from()에 잘못된 값 전달 시 ValueError 발생 확인
|
||||
*/
|
||||
public function test_from_throws_exception_for_invalid_value(): void
|
||||
{
|
||||
$this->expectException(\ValueError::class);
|
||||
|
||||
PermissionType::from('invalid');
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// tryFrom() 정적 메서드 테스트
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* tryFrom()으로 문자열에서 Enum 인스턴스 생성 (유효한 값)
|
||||
*/
|
||||
public function test_try_from_returns_instance_for_valid_value(): void
|
||||
{
|
||||
$admin = PermissionType::tryFrom('admin');
|
||||
$user = PermissionType::tryFrom('user');
|
||||
|
||||
$this->assertInstanceOf(PermissionType::class, $admin);
|
||||
$this->assertInstanceOf(PermissionType::class, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* tryFrom()에 잘못된 값 전달 시 null 반환 확인
|
||||
*/
|
||||
public function test_try_from_returns_null_for_invalid_value(): void
|
||||
{
|
||||
$result = PermissionType::tryFrom('invalid');
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Enums;
|
||||
|
||||
use App\Enums\ScopeType;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ScopeTypeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Self, Role 케이스가 존재해야 합니다.
|
||||
*/
|
||||
public function test_cases_exist(): void
|
||||
{
|
||||
$cases = ScopeType::cases();
|
||||
$this->assertCount(2, $cases);
|
||||
$this->assertSame('self', ScopeType::Self->value);
|
||||
$this->assertSame('role', ScopeType::Role->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* values()가 올바른 값 배열을 반환해야 합니다.
|
||||
*/
|
||||
public function test_values_returns_correct_array(): void
|
||||
{
|
||||
$this->assertSame(['self', 'role'], ScopeType::values());
|
||||
}
|
||||
|
||||
/**
|
||||
* label()이 다국어 라벨을 반환해야 합니다.
|
||||
*/
|
||||
public function test_label_returns_translated_text(): void
|
||||
{
|
||||
$selfLabel = ScopeType::Self->label();
|
||||
$roleLabel = ScopeType::Role->label();
|
||||
|
||||
$this->assertIsString($selfLabel);
|
||||
$this->assertIsString($roleLabel);
|
||||
$this->assertNotEmpty($selfLabel);
|
||||
$this->assertNotEmpty($roleLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* isValid()가 유효한 값에 대해 true를 반환해야 합니다.
|
||||
*/
|
||||
public function test_is_valid_returns_true_for_valid_values(): void
|
||||
{
|
||||
$this->assertTrue(ScopeType::isValid('self'));
|
||||
$this->assertTrue(ScopeType::isValid('role'));
|
||||
}
|
||||
|
||||
/**
|
||||
* isValid()가 무효한 값에 대해 false를 반환해야 합니다.
|
||||
*/
|
||||
public function test_is_valid_returns_false_for_invalid_values(): void
|
||||
{
|
||||
$this->assertFalse(ScopeType::isValid('invalid'));
|
||||
$this->assertFalse(ScopeType::isValid('all'));
|
||||
$this->assertFalse(ScopeType::isValid(''));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user