44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
test('views load fonts from local assets only', function () {
|
|
$externalFontHosts = [
|
|
'fonts.bunny.net',
|
|
'fonts.googleapis.com',
|
|
'fonts.gstatic.com',
|
|
];
|
|
|
|
foreach (File::allFiles(resource_path('views')) as $view) {
|
|
$contents = File::get($view->getRealPath());
|
|
|
|
foreach ($externalFontHosts as $host) {
|
|
$this->assertStringNotContainsString(
|
|
$host,
|
|
$contents,
|
|
$view->getRelativePathname().' references '.$host,
|
|
);
|
|
}
|
|
}
|
|
|
|
$localFontLinks = view('partials.local-fonts')->render();
|
|
|
|
expect($localFontLinks)
|
|
->toContain('fonts/inter-tight/font.css')
|
|
->toContain('fonts/source-serif-4/font.css')
|
|
->toContain('fonts/jetbrains-mono/font.css');
|
|
});
|
|
|
|
test('local font stylesheets reference font files relative to their directories', function () {
|
|
foreach (File::allFiles(public_path('fonts')) as $file) {
|
|
if ($file->getExtension() !== 'css') {
|
|
continue;
|
|
}
|
|
|
|
$this->assertStringNotContainsString(
|
|
'../fonts/',
|
|
File::get($file->getRealPath()),
|
|
$file->getRelativePathname().' still points outside its font directory',
|
|
);
|
|
}
|
|
});
|