*/ private const INTRINSIC = [ 'lockup-on-light' => ['width' => 149, 'height' => 144], 'lockup-on-dark' => ['width' => 149, 'height' => 144], 'mark-on-light' => ['width' => 191, 'height' => 96], 'mark-on-dark' => ['width' => 191, 'height' => 96], ]; public function test_brand_webp_assets_stay_within_their_byte_budget(): void { foreach (array_keys(self::INTRINSIC) as $name) { $path = public_path("brand/{$name}.webp"); $this->assertFileExists($path); $this->assertLessThanOrEqual( self::WEBP_BUDGET, filesize($path), "public/brand/{$name}.webp is over the critical-path budget of " .(self::WEBP_BUDGET / 1024).' KiB. It is eager-loaded on every public page; ' .'re-encode it at the rendered size instead of raising the budget.' ); } } public function test_brand_webp_assets_match_the_dimensions_the_component_declares(): void { $component = (string) file_get_contents( resource_path('views/components/brand/logo.blade.php') ); foreach (self::INTRINSIC as $name => $expected) { $size = getimagesize(public_path("brand/{$name}.webp")); $this->assertIsArray($size, "public/brand/{$name}.webp is not a readable image."); $this->assertSame($expected['width'], $size[0], "public/brand/{$name}.webp width changed."); $this->assertSame($expected['height'], $size[1], "public/brand/{$name}.webp height changed."); } foreach ([['width' => 191, 'height' => 96], ['width' => 149, 'height' => 144]] as $pair) { $this->assertStringContainsString( "'width' => {$pair['width']}, 'height' => {$pair['height']}", $component, 'brand/logo.blade.php must reserve the box using the real intrinsic size of the shipped asset.' ); } } }