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:
203
tests/Feature/Email/IssueEmailContentTest.php
Normal file
203
tests/Feature/Email/IssueEmailContentTest.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Email;
|
||||
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueComment;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Tests\TestCase;
|
||||
use Tests\Traits\SeedsRolesAndPermissions;
|
||||
|
||||
/**
|
||||
* Issue Email Content Tests
|
||||
*
|
||||
* Tests email content for issue tracking-related notifications.
|
||||
*/
|
||||
class IssueEmailContentTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, SeedsRolesAndPermissions;
|
||||
|
||||
protected User $admin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Mail::fake();
|
||||
$this->seedRolesAndPermissions();
|
||||
$this->admin = $this->createAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue assigned email
|
||||
*/
|
||||
public function test_issue_assigned_email(): void
|
||||
{
|
||||
$assignee = User::factory()->create(['email' => 'assignee@test.com']);
|
||||
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'assignee_id' => null,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin)->post(
|
||||
route('admin.issues.assign', $issue),
|
||||
['assignee_id' => $assignee->id]
|
||||
);
|
||||
|
||||
$issue->refresh();
|
||||
$this->assertEquals($assignee->id, $issue->assignee_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue status changed email
|
||||
*/
|
||||
public function test_issue_status_changed_email(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'status' => Issue::STATUS_NEW,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin)->patch(
|
||||
route('admin.issues.status', $issue),
|
||||
['status' => Issue::STATUS_IN_PROGRESS]
|
||||
);
|
||||
|
||||
$issue->refresh();
|
||||
$this->assertEquals(Issue::STATUS_IN_PROGRESS, $issue->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue commented email
|
||||
*/
|
||||
public function test_issue_commented_email(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin)->post(
|
||||
route('admin.issues.comments.store', $issue),
|
||||
['content' => 'This is a test comment']
|
||||
);
|
||||
|
||||
$this->assertDatabaseHas('issue_comments', [
|
||||
'issue_id' => $issue->id,
|
||||
'content' => 'This is a test comment',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue due soon email
|
||||
*/
|
||||
public function test_issue_due_soon_email(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'due_date' => now()->addDays(2),
|
||||
'status' => Issue::STATUS_IN_PROGRESS,
|
||||
]);
|
||||
|
||||
// Issue is due soon (within 3 days)
|
||||
$this->assertTrue($issue->due_date->diffInDays(now()) <= 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue overdue email
|
||||
*/
|
||||
public function test_issue_overdue_email(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'due_date' => now()->subDay(),
|
||||
'status' => Issue::STATUS_IN_PROGRESS,
|
||||
]);
|
||||
|
||||
$this->assertTrue($issue->isOverdue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test issue closed email
|
||||
*/
|
||||
public function test_issue_closed_email(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'status' => Issue::STATUS_REVIEW,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin)->patch(
|
||||
route('admin.issues.status', $issue),
|
||||
['status' => Issue::STATUS_CLOSED]
|
||||
);
|
||||
|
||||
$issue->refresh();
|
||||
$this->assertEquals(Issue::STATUS_CLOSED, $issue->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test email sent to watchers
|
||||
*/
|
||||
public function test_email_sent_to_watchers(): void
|
||||
{
|
||||
$watcher = User::factory()->create(['email' => 'watcher@test.com']);
|
||||
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin)->post(
|
||||
route('admin.issues.watchers.store', $issue),
|
||||
['user_id' => $watcher->id]
|
||||
);
|
||||
|
||||
// Watcher should be added
|
||||
$this->assertTrue($issue->watchers->contains($watcher));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test email contains issue link
|
||||
*/
|
||||
public function test_email_contains_issue_link(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
]);
|
||||
|
||||
$issueUrl = route('admin.issues.show', $issue);
|
||||
$this->assertStringContainsString('/admin/issues/', $issueUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test email contains issue details
|
||||
*/
|
||||
public function test_email_contains_issue_details(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'title' => 'Important Task',
|
||||
'description' => 'This needs to be done urgently',
|
||||
'priority' => Issue::PRIORITY_HIGH,
|
||||
]);
|
||||
|
||||
$this->assertEquals('Important Task', $issue->title);
|
||||
$this->assertEquals('This needs to be done urgently', $issue->description);
|
||||
$this->assertEquals(Issue::PRIORITY_HIGH, $issue->priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test email formatting is correct
|
||||
*/
|
||||
public function test_email_formatting_is_correct(): void
|
||||
{
|
||||
$issue = Issue::factory()->create([
|
||||
'created_by_user_id' => $this->admin->id,
|
||||
'title' => 'Test Issue',
|
||||
]);
|
||||
|
||||
// Verify issue number is properly formatted
|
||||
$this->assertMatchesRegularExpression('/ISS-\d{4}-\d+/', $issue->issue_number);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user