Add production provider deps/config so transactional email and CMS media can use Resend and a dedicated r2 disk with custom-domain URLs. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
afterEach(function (): void {
|
|
foreach ([
|
|
'R2_ACCESS_KEY_ID',
|
|
'R2_SECRET_ACCESS_KEY',
|
|
'R2_BUCKET',
|
|
'R2_ENDPOINT',
|
|
'R2_URL',
|
|
] as $key) {
|
|
putenv($key);
|
|
unset($_ENV[$key], $_SERVER[$key]);
|
|
}
|
|
});
|
|
|
|
it('defines an r2 disk with the s3 driver and path-style endpoint', function (): void {
|
|
$disk = config('filesystems.disks.r2');
|
|
|
|
expect($disk)->toBeArray()
|
|
->and($disk['driver'])->toBe('s3')
|
|
->and($disk['use_path_style_endpoint'])->toBeTrue();
|
|
});
|
|
|
|
it('resolves r2 credentials endpoint bucket and url from R2 env vars', function (): void {
|
|
putenv('R2_ACCESS_KEY_ID=r2-key');
|
|
putenv('R2_SECRET_ACCESS_KEY=r2-secret');
|
|
putenv('R2_BUCKET=amare-media');
|
|
putenv('R2_ENDPOINT=https://accountid.r2.cloudflarestorage.com');
|
|
putenv('R2_URL=https://media.example.com');
|
|
$_ENV['R2_ACCESS_KEY_ID'] = 'r2-key';
|
|
$_ENV['R2_SECRET_ACCESS_KEY'] = 'r2-secret';
|
|
$_ENV['R2_BUCKET'] = 'amare-media';
|
|
$_ENV['R2_ENDPOINT'] = 'https://accountid.r2.cloudflarestorage.com';
|
|
$_ENV['R2_URL'] = 'https://media.example.com';
|
|
$_SERVER['R2_ACCESS_KEY_ID'] = 'r2-key';
|
|
$_SERVER['R2_SECRET_ACCESS_KEY'] = 'r2-secret';
|
|
$_SERVER['R2_BUCKET'] = 'amare-media';
|
|
$_SERVER['R2_ENDPOINT'] = 'https://accountid.r2.cloudflarestorage.com';
|
|
$_SERVER['R2_URL'] = 'https://media.example.com';
|
|
|
|
$filesystems = require config_path('filesystems.php');
|
|
$disk = $filesystems['disks']['r2'];
|
|
|
|
expect($disk['key'])->toBe('r2-key')
|
|
->and($disk['secret'])->toBe('r2-secret')
|
|
->and($disk['bucket'])->toBe('amare-media')
|
|
->and($disk['endpoint'])->toBe('https://accountid.r2.cloudflarestorage.com')
|
|
->and($disk['url'])->toBe('https://media.example.com')
|
|
->and($disk['use_path_style_endpoint'])->toBeTrue()
|
|
->and($disk['visibility'])->toBe('public');
|
|
});
|
|
|
|
it('uses r2 as the default disk when FILESYSTEM_DISK is r2', function (): void {
|
|
config(['filesystems.default' => 'r2']);
|
|
|
|
expect(config('filesystems.default'))->toBe('r2');
|
|
});
|