You've already forked Atomcms-edit
75 lines
3.3 KiB
PHP
Executable File
75 lines
3.3 KiB
PHP
Executable File
<?php
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Test Case
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
|
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
|
| need to change it using the "uses()" function to bind a different classes or traits.
|
|
|
|
|
*/
|
|
|
|
use App\Models\Miscellaneous\WebsiteInstallation;
|
|
use App\Models\Miscellaneous\WebsiteSetting;
|
|
use App\Services\InstallationService;
|
|
use App\Services\SettingsService;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class)->in('Feature');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Expectations
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| When you're writing tests, you often need to check that values meet certain conditions. The
|
|
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
|
| to assert different things. Of course, you may extend the Expectation API at any time.
|
|
|
|
|
*/
|
|
|
|
expect()->extend('toBeOne', function () {
|
|
return $this->toBe(1);
|
|
});
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Functions
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
|
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
|
| global functions to help you to reduce the number of lines of code in your test files.
|
|
|
|
|
*/
|
|
|
|
function installHotel(): void
|
|
{
|
|
// Clear all caches first
|
|
SettingsService::clearCache();
|
|
InstallationService::clearCache();
|
|
Cache::forget('installation_record');
|
|
|
|
// Delete existing installation record to prevent IP conflicts
|
|
WebsiteInstallation::query()->delete();
|
|
|
|
WebsiteInstallation::create(['completed' => true, 'installation_key' => 'key', 'step' => 0]);
|
|
|
|
WebsiteSetting::firstOrCreate(['key' => 'max_accounts_per_ip'], ['value' => 10, 'comment' => '']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'theme'], ['value' => 'atom', 'comment' => 'Theme']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'disable_registration'], ['value' => '0', 'comment' => 'Disable registration']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'requires_beta_code'], ['value' => '0', 'comment' => 'Requires beta code']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'username_regex'], ['value' => '/^[a-zA-Z0-9_.-]+$/', 'comment' => 'Username regex']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'start_motto'], ['value' => 'Welcome to the hotel!', 'comment' => 'Start motto']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'start_look'], ['value' => 'hr-100-61.hd-180-1.ch-210-66.lg-270-110.sh-305-62', 'comment' => 'Start look']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'start_credits'], ['value' => '1000', 'comment' => 'Start credits']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'hotel_home_room'], ['value' => '0', 'comment' => 'Hotel home room']);
|
|
WebsiteSetting::firstOrCreate(['key' => 'enable_discord_webhook'], ['value' => '0', 'comment' => 'Enable Discord webhook']);
|
|
|
|
// Clear settings cache again to ensure fresh data
|
|
SettingsService::clearCache();
|
|
}
|