feat: complete CHRNX responsive content states

This commit is contained in:
chrnx committed 2026-08-12 08:42:20 -05:00
1 parent 9385c1b9fb
commit 5073178492
60 files changed
+1699 -22

No files matched your search

+5 -4
View File
@@ -59,10 +59,11 @@ class PatternsTest extends WP_UnitTestCase {
/** Local art is generated through escaped theme URIs with intrinsic dimensions. */
public function test_art_patterns_use_only_escaped_local_theme_images() {
foreach ( array( 'home-music', 'music-landing', 'podcast-landing', 'podcast-show' ) as $name ) {
$source = file_get_contents( get_theme_file_path( 'patterns/' . $name . '.php' ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture.
$content = $this->render_pattern( get_theme_file_path( 'patterns/' . $name . '.php' ) );
$this->assertStringContainsString( 'get_theme_file_uri(', $source, $name );
$this->assertStringContainsString( 'esc_url(', $source, $name );
$source = file_get_contents( get_theme_file_path( 'patterns/' . $name . '.php' ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture.
$content = $this->render_pattern( get_theme_file_path( 'patterns/' . $name . '.php' ) );
$uses_responsive_helper = str_contains( $source, 'chrnx_get_topic_portrait_markup(' );
$uses_direct_uri = str_contains( $source, 'get_theme_file_uri(' ) && str_contains( $source, 'esc_url(' );
$this->assertTrue( $uses_responsive_helper || $uses_direct_uri, $name );
$this->assertMatchesRegularExpression( '/<img\b[^>]*\bwidth="1122"[^>]*\bheight="1402"/i', $content, $name );
$this->assertMatchesRegularExpression( '/<img\b[^>]*\bloading="lazy"[^>]*\bdecoding="async"/i', $content, $name );
}