get_registered( 'chrnx/' . $name );
$this->assertInstanceOf( WP_Block_Type::class, $type, $name );
$this->assertTrue( is_callable( $type->render_callback ), $name );
}
}
/** The approved local wordmark links to the portable site home URL. */
public function test_site_brand_renders_escaped_local_home_and_wordmark_urls() {
$output = render_block(
array(
'blockName' => 'chrnx/site-brand',
'attrs' => array(),
'innerBlocks' => array(),
'innerHTML' => '',
'innerContent' => array(),
)
);
$this->assertStringContainsString( 'href="' . esc_url( home_url( '/' ) ) . '"', $output );
$this->assertStringContainsString( 'src="' . esc_url( get_theme_file_uri( 'assets/icons/chrnx-wordmark.svg' ) ) . '"', $output );
$this->assertStringContainsString( 'alt="CHRNX"', $output );
$this->assertStringContainsString( 'href="#chrnx-main"', $output );
}
/** Topic art is an exact fixed mapping and rejects arbitrary paths. */
public function test_topic_art_uses_only_the_fixed_mapping() {
$expected = array(
'research' => 'alter-ego-research.png',
'code' => 'alter-ego-code.png',
'literature' => 'alter-ego-literature.png',
'music' => 'the-no-names-musician-cutout.png',
'podcasts' => 'alter-ego-podcasts.png',
'life' => 'alter-ego-life.png',
'gaming' => 'alter-ego-gaming.png',
);
foreach ( $expected as $slug => $filename ) {
$this->assertSame( 'assets/images/' . $filename, chrnx_get_topic_art_asset( $slug ) );
}
foreach ( array( '', 'unknown', '../secret.png', 'assets/images/anything.png' ) as $value ) {
$this->assertSame( '', chrnx_get_topic_art_asset( $value ) );
}
}
/** Podcast metadata renders known text and HTTPS links, never embed HTML. */
public function test_podcast_meta_renders_only_known_escaped_fields() {
$post_id = self::factory()->post->create( array( 'post_title' => 'Episode' ) );
update_post_meta( $post_id, 'chrnx_episode_number', 42 );
update_post_meta( $post_id, 'chrnx_episode_duration', '1:02:03' );
update_post_meta( $post_id, 'chrnx_episode_participants', array( 'Ada & Bob', '' ) );
update_post_meta( $post_id, 'canonical_episode_url', 'https://example.test/episode' );
update_post_meta( $post_id, 'chrnx_buzzsprout_embed', '' );
$output = $this->render_for_post( 'chrnx/podcast-meta', $post_id );
$this->assertStringContainsString( '42', $output );
$this->assertStringContainsString( '1:02:03', $output );
$this->assertStringContainsString( 'Ada & Bob', $output );
$this->assertStringContainsString( 'https://example.test/episode', $output );
$this->assertStringNotContainsString( '';
$post_id = self::factory()->post->create( array( 'post_title' => $title ) );
$output = render_block(
array(
'blockName' => 'chrnx/featured-stories',
'attrs' => array( 'limit' => 1 ),
'innerBlocks' => array(),
'innerHTML' => '',
'innerContent' => array(),
)
);
$this->assertSame( $post_id, chrnx_get_featured_story_ids( 1 )[0] );
$this->assertStringContainsString( esc_html( get_the_title( $post_id ) ), $output );
$this->assertStringNotContainsString( '