- Add highly optimized Dockerfile with Nginx and PHP-FPM 8.4 - Add docker-compose.yml configured with Redis and MariaDB 10.11 - Implement entrypoint.sh and supervisord.conf for background workers - Refactor legacy IMAP scripts into scheduled Artisan Commands - Secure app by removing old routes with hardcoded basic auth credentials - Configure email attachments to use Laravel Storage instead of insecure public/tmp
94 lines
3.4 KiB
PHP
94 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Concerns;
|
|
|
|
use App\Models\Blog;
|
|
use App\Models\Menu;
|
|
use App\Models\Plan;
|
|
use Exception;
|
|
use Illuminate\Support\Collection;
|
|
|
|
trait LoadsApplicationData
|
|
{
|
|
/**
|
|
* Load application data for testing.
|
|
*/
|
|
protected function loadApplicationData(): void
|
|
{
|
|
// For testing, set up mock configuration data
|
|
$settings = [
|
|
'app_name' => 'ZEmailnator',
|
|
'app_base_url' => 'http://localhost:8000',
|
|
'app_title' => 'ZEmailnator - Temporary Email Service',
|
|
'app_description' => 'Create temporary email addresses instantly',
|
|
'app_keyword' => 'temp email, disposable email, fake email',
|
|
'app_meta' => json_encode([
|
|
'author' => 'ZEmailnator',
|
|
'robots' => 'index, follow',
|
|
]),
|
|
'imap_settings' => json_encode([
|
|
'host' => 'imap.gmail.com',
|
|
'port' => 993,
|
|
'protocol' => 'imap',
|
|
'encryption' => 'ssl',
|
|
'validate_cert' => true,
|
|
'username' => 'test@gmail.com',
|
|
'password' => 'password',
|
|
]),
|
|
'configuration_settings' => json_encode([
|
|
'custom_username_length_min' => 3,
|
|
'custom_username_length_max' => 20,
|
|
'random_username_length_min' => 6,
|
|
'random_username_length_max' => 12,
|
|
'forbidden_ids' => ['admin', 'root', 'test'],
|
|
'gmailUsernames' => ['john.doe', 'jane.smith'],
|
|
'outlookUsernames' => ['outlookuser', 'testuser'],
|
|
'domains' => ['gmail.com', 'outlook.com', 'example.com'],
|
|
'enable_create_from_url' => true,
|
|
'disable_mailbox_slug' => false,
|
|
'fetch_messages_limit' => 15,
|
|
'blocked_domains' => ['spam.com', 'blocked.com'],
|
|
'date_format' => 'd M Y h:i A',
|
|
'add_mail_in_title' => false,
|
|
'fetch_seconds' => 30,
|
|
]),
|
|
'ads_settings' => json_encode([
|
|
'enabled' => false,
|
|
'provider' => 'google',
|
|
'one' => '<!-- Ad content placeholder -->',
|
|
'two' => '<!-- Ad content placeholder -->',
|
|
]),
|
|
];
|
|
|
|
// Try to load data from database, but fail gracefully if tables don't exist
|
|
try {
|
|
$menus = cache()->remember('app_menus', now()->addHours(6), Menu::all(...));
|
|
|
|
$blogs = cache()->remember('app_blogs', now()->addHours(6), fn () => Blog::query()->where('is_published', 1)->get());
|
|
|
|
$plans = cache()->remember('app_plans', now()->addHours(6), Plan::all(...));
|
|
} catch (Exception) {
|
|
// Set empty collections if database tables don't exist
|
|
$menus = collect();
|
|
$blogs = collect();
|
|
$plans = collect();
|
|
}
|
|
|
|
// Ensure we always have collections, even if cache is empty
|
|
if (! ($menus instanceof Collection)) {
|
|
$menus = collect();
|
|
}
|
|
if (! ($blogs instanceof Collection)) {
|
|
$blogs = collect();
|
|
}
|
|
if (! ($plans instanceof Collection)) {
|
|
$plans = collect();
|
|
}
|
|
|
|
config(['app.settings' => $settings]);
|
|
config(['app.menus' => $menus]);
|
|
config(['app.blogs' => $blogs]);
|
|
config(['app.plans' => $plans]);
|
|
}
|
|
}
|