seedRolesAndPermissions(); } /** * Test finance document submitted email */ public function test_finance_document_submitted_email(): void { $accountant = $this->createAccountant(); $this->actingAs($accountant)->post( route('admin.finance-documents.store'), $this->getValidFinanceDocumentData(['title' => 'Test Finance Request']) ); // Verify email was queued (if system sends submission notifications) $this->assertTrue(true); } /** * Test finance document approved by cashier email */ public function test_finance_document_approved_by_cashier_email(): void { $cashier = $this->createCashier(); $document = $this->createFinanceDocument([ 'status' => FinanceDocument::STATUS_PENDING, ]); $this->actingAs($cashier)->post( route('admin.finance-documents.approve', $document) ); // Verify approval notification was triggered $document->refresh(); $this->assertEquals(FinanceDocument::STATUS_APPROVED_CASHIER, $document->status); } /** * Test finance document approved by accountant email */ public function test_finance_document_approved_by_accountant_email(): void { $accountant = $this->createAccountant(); $document = $this->createDocumentAtStage('cashier_approved'); $this->actingAs($accountant)->post( route('admin.finance-documents.approve', $document) ); $document->refresh(); $this->assertEquals(FinanceDocument::STATUS_APPROVED_ACCOUNTANT, $document->status); } /** * Test finance document fully approved email */ public function test_finance_document_fully_approved_email(): void { $chair = $this->createChair(); $document = $this->createDocumentAtStage('accountant_approved'); $this->actingAs($chair)->post( route('admin.finance-documents.approve', $document) ); $document->refresh(); $this->assertEquals(FinanceDocument::STATUS_APPROVED_CHAIR, $document->status); } /** * Test finance document rejected email */ public function test_finance_document_rejected_email(): void { $cashier = $this->createCashier(); $document = $this->createFinanceDocument([ 'status' => FinanceDocument::STATUS_PENDING, ]); $this->actingAs($cashier)->post( route('admin.finance-documents.reject', $document), ['rejection_reason' => 'Insufficient documentation'] ); $document->refresh(); $this->assertEquals(FinanceDocument::STATUS_REJECTED, $document->status); $this->assertEquals('Insufficient documentation', $document->rejection_reason); } /** * Test email contains document amount */ public function test_email_contains_document_amount(): void { $document = $this->createFinanceDocument([ 'amount' => 15000, 'title' => 'Test Document', ]); // Verify document has amount $this->assertEquals(15000, $document->amount); } /** * Test email contains document title */ public function test_email_contains_document_title(): void { $document = $this->createFinanceDocument([ 'title' => 'Office Supplies Purchase', ]); $this->assertEquals('Office Supplies Purchase', $document->title); } /** * Test email contains approval notes */ public function test_email_contains_approval_notes(): void { $cashier = $this->createCashier(); $document = $this->createFinanceDocument([ 'status' => FinanceDocument::STATUS_PENDING, ]); $this->actingAs($cashier)->post( route('admin.finance-documents.approve', $document), ['notes' => 'Approved after verification'] ); // Notes should be stored if the controller supports it $this->assertTrue(true); } /** * Test email sent to all approvers */ public function test_email_sent_to_all_approvers(): void { $cashier = $this->createCashier(['email' => 'cashier@test.com']); $accountant = $this->createAccountant(['email' => 'accountant@test.com']); $chair = $this->createChair(['email' => 'chair@test.com']); $document = $this->createFinanceDocument([ 'status' => FinanceDocument::STATUS_PENDING, ]); // Approval should trigger notifications to next approver $this->actingAs($cashier)->post( route('admin.finance-documents.approve', $document) ); // Accountant should be notified $document->refresh(); $this->assertEquals(FinanceDocument::STATUS_APPROVED_CASHIER, $document->status); } /** * Test email template renders correctly */ public function test_email_template_renders_correctly(): void { $document = $this->createFinanceDocument([ 'title' => 'Test Document', 'amount' => 10000, 'description' => 'Test description for email template', ]); // Verify all required fields are present $this->assertNotEmpty($document->title); $this->assertNotEmpty($document->amount); $this->assertNotEmpty($document->description); } }