You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models {
|
|
final class Configurations
|
|
{
|
|
public static string $value = '';
|
|
public static bool $throw = false;
|
|
|
|
public static function where($column, $value): object
|
|
{
|
|
if (self::$throw) {
|
|
throw new \RuntimeException('Configuration storage unavailable.');
|
|
}
|
|
|
|
return new class {
|
|
public function value($column): string
|
|
{
|
|
return Configurations::$value;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace App\Services {
|
|
final class RedisClient
|
|
{
|
|
public function get($key, $minutes = null, $callback = null)
|
|
{
|
|
return $callback === null ? null : $callback();
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace {
|
|
use App\Models\Configurations;
|
|
use App\Services\SiteName;
|
|
|
|
require dirname(__DIR__) . '/app/Services/SiteName.php';
|
|
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new \RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$_SERVER['HTTP_HOST'] = 'mapped.example.test';
|
|
Configurations::$value = 'Default Site Title';
|
|
$assert(
|
|
SiteName::defaultName() === 'Default Site Title',
|
|
'The mail identity did not read the administrator default title.'
|
|
);
|
|
|
|
Configurations::$value = " \t ";
|
|
$assert(
|
|
SiteName::defaultName() === 'Site',
|
|
'An empty default title did not use the English mail fallback.'
|
|
);
|
|
|
|
Configurations::$throw = true;
|
|
$assert(
|
|
SiteName::defaultName() === 'Site',
|
|
'A configuration read failure did not use the English mail fallback.'
|
|
);
|
|
|
|
echo 'Site default-title checks passed.' . PHP_EOL;
|
|
}
|