- Added fonts:sync-google command (uses GOOGLE_FONTS_API_KEY, generates /public/fonts/google files, manifest, CSS, cache flush) and
exposed manifest via new GET /api/v1/tenant/fonts endpoint with fallbacks for existing local fonts.
- Imported generated fonts CSS, added API client + font loader hook, and wired branding page font fields to searchable selects (with
custom override) that auto-load selected fonts.
- Invites layout editor now offers font selection per element with runtime font loading for previews/export alignment.
- New tests cover font sync command and font manifest API.
Tests run: php artisan test --filter=Fonts --testsuite=Feature.
Note: repository already has other modified files (e.g., EventPublicController, SettingsStoreRequest, guest components, etc.); left
untouched. Run php artisan fonts:sync-google after setting the API key to populate /public/fonts/google.
77 lines
2.5 KiB
PHP
77 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Console;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
class SyncGoogleFontsTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
config()->set('services.google_fonts.key', 'test-key');
|
|
}
|
|
|
|
public function test_it_downloads_fonts_and_writes_manifest(): void
|
|
{
|
|
$targetPath = storage_path('app/test-fonts');
|
|
File::deleteDirectory($targetPath);
|
|
|
|
Http::fake([
|
|
'https://www.googleapis.com/webfonts/v1/webfonts*' => Http::response([
|
|
'items' => [
|
|
[
|
|
'family' => 'Alpha Sans',
|
|
'category' => 'sans-serif',
|
|
'variants' => ['regular', '700'],
|
|
'files' => [
|
|
'regular' => 'https://fonts.gstatic.com/s/alpha-regular.woff2',
|
|
'700' => 'https://fonts.gstatic.com/s/alpha-700.woff2',
|
|
],
|
|
],
|
|
[
|
|
'family' => 'Beta Serif',
|
|
'category' => 'serif',
|
|
'variants' => ['regular'],
|
|
'files' => [
|
|
'regular' => 'https://fonts.gstatic.com/s/beta-regular.ttf',
|
|
],
|
|
],
|
|
],
|
|
]),
|
|
'https://fonts.gstatic.com/*' => Http::response('font-binary', 200),
|
|
]);
|
|
|
|
Artisan::call('fonts:sync-google', [
|
|
'--count' => 2,
|
|
'--weights' => '400,700',
|
|
'--path' => 'storage/app/test-fonts',
|
|
'--force' => true,
|
|
]);
|
|
|
|
$manifestPath = $targetPath.'/manifest.json';
|
|
$cssPath = $targetPath.'/fonts.css';
|
|
|
|
$this->assertFileExists($manifestPath);
|
|
$this->assertFileExists($cssPath);
|
|
|
|
$manifest = json_decode(File::get($manifestPath), true);
|
|
$this->assertSame(2, $manifest['count']);
|
|
$this->assertCount(2, $manifest['fonts']);
|
|
|
|
$family = collect($manifest['fonts']);
|
|
$this->assertTrue($family->pluck('family')->contains('Alpha Sans'));
|
|
$this->assertTrue($family->pluck('family')->contains('Beta Serif'));
|
|
|
|
$this->assertTrue(str_contains(File::get($cssPath), "font-family: 'Alpha Sans';"));
|
|
$this->assertTrue(str_contains(File::get($cssPath), "font-family: 'Beta Serif';"));
|
|
|
|
File::deleteDirectory($targetPath);
|
|
}
|
|
}
|
|
|