@@ -94,6 +94,13 @@ class TestablePaymentController extends PaymentController
|
||||
|
||||
class PaymentControllerRegressionTest extends CIUnitTestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
session()->remove('user_id');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testRedirectPageSendsUsersBackToInvoicePaymentWithInfoMessage(): void
|
||||
{
|
||||
$controller = new TestablePaymentController();
|
||||
@@ -134,5 +141,27 @@ class PaymentControllerRegressionTest extends CIUnitTestCase
|
||||
$this->assertSame('proofs/check-123.pdf', $model->inserted[0]['proof_path']);
|
||||
$this->assertSame('INV-001', $model->inserted[0]['invoice_number']);
|
||||
}
|
||||
|
||||
public function testManualPostStoresLoggedInUserIdAsUpdateBy(): void
|
||||
{
|
||||
session()->set('user_id', 42);
|
||||
|
||||
$model = new ManualPaymentModelSpy();
|
||||
$controller = (new TestablePaymentController())
|
||||
->setManualPaymentModel($model)
|
||||
->setAttachmentService(new AttachmentServiceStub())
|
||||
->setRequestObject(new PaymentRequestStub('post', [
|
||||
'invoice_number' => 'INV-002',
|
||||
'amount' => '75.00',
|
||||
'payment_method' => 'cash',
|
||||
'reference' => 'CASH-42',
|
||||
]));
|
||||
|
||||
$response = $controller->manual();
|
||||
|
||||
$this->assertInstanceOf(RedirectResponse::class, $response);
|
||||
$this->assertCount(1, $model->inserted);
|
||||
$this->assertSame(42, $model->inserted[0]['update_by']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user