Add membership fee system with disability discount and fix document permissions
Features: - Implement two fee types: entrance fee and annual fee (both NT$1,000) - Add 50% discount for disability certificate holders - Add disability certificate upload in member profile - Integrate disability verification into cashier approval workflow - Add membership fee settings in system admin Document permissions: - Fix hard-coded role logic in Document model - Use permission-based authorization instead of role checks Additional features: - Add announcements, general ledger, and trial balance modules - Add income management and accounting entries - Add comprehensive test suite with factories - Update UI translations to Traditional Chinese 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
145
tests/Feature/Validation/IssueValidationTest.php
Normal file
145
tests/Feature/Validation/IssueValidationTest.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Validation;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueComment;
|
||||
use App\Models\IssueLabel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\SeedsRolesAndPermissions;
|
||||
|
||||
/**
|
||||
* Issue Validation Tests
|
||||
*
|
||||
* Tests validation rules and model behavior for issue tracking functionality.
|
||||
*/
|
||||
class IssueValidationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, SeedsRolesAndPermissions;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedRolesAndPermissions();
|
||||
}
|
||||
|
||||
public function test_issue_number_is_generated(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$issue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
|
||||
$this->assertNotEmpty($issue->issue_number);
|
||||
$this->assertMatchesRegularExpression('/^ISS-\d{4}-\d+$/', $issue->issue_number);
|
||||
}
|
||||
|
||||
public function test_issue_defaults_to_new_status(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$issue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
|
||||
$this->assertEquals(Issue::STATUS_NEW, $issue->status);
|
||||
}
|
||||
|
||||
public function test_issue_can_have_assignee(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$assignee = $this->createAdmin();
|
||||
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $admin->id,
|
||||
'assigned_to_user_id' => $assignee->id,
|
||||
]);
|
||||
|
||||
$this->assertEquals($assignee->id, $issue->assigned_to_user_id);
|
||||
$this->assertEquals($assignee->id, $issue->assignee->id);
|
||||
}
|
||||
|
||||
public function test_issue_can_have_due_date(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$dueDate = now()->addWeek();
|
||||
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $admin->id,
|
||||
'due_date' => $dueDate,
|
||||
]);
|
||||
|
||||
$this->assertTrue($issue->due_date->isSameDay($dueDate));
|
||||
}
|
||||
|
||||
public function test_issue_can_have_parent(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
|
||||
$parentIssue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
$childIssue = Issue::factory()->create([
|
||||
'created_by_user_id' => $admin->id,
|
||||
'parent_issue_id' => $parentIssue->id,
|
||||
]);
|
||||
|
||||
$this->assertEquals($parentIssue->id, $childIssue->parent_issue_id);
|
||||
$this->assertEquals($parentIssue->id, $childIssue->parentIssue->id);
|
||||
}
|
||||
|
||||
public function test_issue_can_have_subtasks(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
|
||||
$parentIssue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
|
||||
Issue::factory()->count(3)->create([
|
||||
'created_by_user_id' => $admin->id,
|
||||
'parent_issue_id' => $parentIssue->id,
|
||||
]);
|
||||
|
||||
$this->assertCount(3, $parentIssue->subTasks);
|
||||
}
|
||||
|
||||
public function test_issue_can_have_comments(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$issue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
|
||||
IssueComment::factory()->count(5)->create([
|
||||
'issue_id' => $issue->id,
|
||||
'user_id' => $admin->id,
|
||||
]);
|
||||
|
||||
$this->assertCount(5, $issue->comments);
|
||||
}
|
||||
|
||||
public function test_issue_can_have_labels(): void
|
||||
{
|
||||
$admin = $this->createAdmin();
|
||||
$issue = Issue::factory()->create(['created_by_user_id' => $admin->id]);
|
||||
$labels = IssueLabel::factory()->count(3)->create();
|
||||
|
||||
$issue->labels()->attach($labels->pluck('id'));
|
||||
|
||||
$this->assertCount(3, $issue->labels);
|
||||
}
|
||||
|
||||
public function test_issue_status_constants(): void
|
||||
{
|
||||
$this->assertEquals('new', Issue::STATUS_NEW);
|
||||
$this->assertEquals('in_progress', Issue::STATUS_IN_PROGRESS);
|
||||
$this->assertEquals('closed', Issue::STATUS_CLOSED);
|
||||
}
|
||||
|
||||
public function test_issue_priority_constants(): void
|
||||
{
|
||||
$this->assertEquals('low', Issue::PRIORITY_LOW);
|
||||
$this->assertEquals('medium', Issue::PRIORITY_MEDIUM);
|
||||
$this->assertEquals('high', Issue::PRIORITY_HIGH);
|
||||
$this->assertEquals('urgent', Issue::PRIORITY_URGENT);
|
||||
}
|
||||
|
||||
public function test_issue_type_constants(): void
|
||||
{
|
||||
$this->assertEquals('work_item', Issue::TYPE_WORK_ITEM);
|
||||
$this->assertEquals('project_task', Issue::TYPE_PROJECT_TASK);
|
||||
$this->assertEquals('maintenance', Issue::TYPE_MAINTENANCE);
|
||||
$this->assertEquals('member_request', Issue::TYPE_MEMBER_REQUEST);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user