79 lines
2.6 KiB
PHP
79 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
putenv('EMAIL_FAKE_MODE=1');
|
|
|
|
usesApiSuite();
|
|
|
|
it('allows department admins to resend order booking confirmations', function (): void {
|
|
$customer = api_fixtures()->createUser([
|
|
'display_name' => 'Resend Booking Confirmation Customer',
|
|
'email' => 'resend-booking-confirmation@example.test',
|
|
]);
|
|
$branding = api_fixtures()->createBranding([
|
|
'name' => 'Resend Booking Confirmation Brand',
|
|
'address' => 'Resend Booking Confirmation Address 1',
|
|
]);
|
|
$department = api_fixtures()->createDepartment([
|
|
'name' => 'Resend Booking Confirmation Department',
|
|
'branding' => $branding['id'],
|
|
]);
|
|
$booking = api_fixtures()->createOrderBooking([
|
|
'customer_number' => $customer['customer_number'],
|
|
'department' => $department['id'],
|
|
'reference' => 'RESEND-CONFIRMATION',
|
|
'reg_1' => 'RESEND1',
|
|
]);
|
|
$session = api_fixtures()->createUserSession([
|
|
'resend_booking_confirmations',
|
|
'department_access_' . $department['id'],
|
|
]);
|
|
|
|
$response = api_client()->post('/order-bookings/booking-confirmation/resend', [
|
|
'id' => $booking['id'],
|
|
], $session['headers']);
|
|
|
|
$response
|
|
->assertStatus(200)
|
|
->assertEnvelope()
|
|
->assertSuccess();
|
|
|
|
expect($response->data())
|
|
->toBeArray()
|
|
->toHaveKey('message', 'Booking confirmation resent successfully.')
|
|
->toHaveKey('booking')
|
|
->and($response->data()['booking'])
|
|
->toBeArray()
|
|
->and($response->data()['booking']['id'] ?? null)
|
|
->toBe($booking['id'])
|
|
->and($response->data()['booking']['reference'] ?? null)
|
|
->toBe('RESEND-CONFIRMATION');
|
|
});
|
|
|
|
it('requires department access when resending order booking confirmations', function (): void {
|
|
$customer = api_fixtures()->createUser([
|
|
'display_name' => 'Resend Booking Confirmation Foreign Customer',
|
|
]);
|
|
$department = api_fixtures()->createDepartment([
|
|
'name' => 'Resend Booking Confirmation Foreign Department',
|
|
]);
|
|
$booking = api_fixtures()->createOrderBooking([
|
|
'customer_number' => $customer['customer_number'],
|
|
'department' => $department['id'],
|
|
]);
|
|
$session = api_fixtures()->createUserSession([
|
|
'resend_booking_confirmations',
|
|
]);
|
|
|
|
$response = api_client()->post('/order-bookings/booking-confirmation/resend', [
|
|
'id' => $booking['id'],
|
|
], $session['headers']);
|
|
|
|
$response
|
|
->assertStatus(403)
|
|
->assertEnvelope()
|
|
->assertSuccess(false)
|
|
->assertMissingPermissions(['department_access_' . $department['id']]);
|
|
});
|