term->create( array( 'taxonomy' => 'chrnx_project', 'name' => 'Green Tea', 'slug' => 'green-tea-test', ) ); update_term_meta( $term_id, 'chrnx_project_status', 'Beta' ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'chrnx-project-card', $markup ); $this->assertStringContainsString( 'Green Tea', $markup ); $this->assertStringContainsString( 'Beta', $markup ); } /** * Ensure stored project links render with their platform icons. */ public function test_project_list_renders_stored_links() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'name' => 'Matcha CLI', 'slug' => 'matcha-cli-test', ) ); update_term_meta( $term_id, 'chrnx_project_repo', 'https://example.com/repo' ); update_term_meta( $term_id, 'chrnx_project_package', 'https://example.com/package' ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'chrnx-platform-links', $markup ); $this->assertStringContainsString( 'https://example.com/repo', $markup ); $this->assertStringContainsString( 'https://example.com/package', $markup ); } /** * Ensure a project without a cover still renders art. */ public function test_project_without_cover_uses_placeholder_art() { self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'slug' => 'coverless-test', ) ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'chrnx-project-card__fallback', $markup ); } /** * Ensure the detail block renders the queried project header. */ public function test_project_detail_renders_the_queried_term() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'name' => 'Ailed', 'slug' => 'ailed-test', 'description' => 'A chess engine that feels.', ) ); update_term_meta( $term_id, 'chrnx_project_repo', 'https://github.com/example/ailed' ); update_term_meta( $term_id, 'chrnx_project_status', 'Activo' ); $this->go_to( get_term_link( $term_id ) ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'A chess engine that feels.', $markup ); $this->assertStringContainsString( 'https://github.com/example/ailed', $markup ); $this->assertStringContainsString( 'Activo', $markup ); } /** * Ensure the detail block renders nothing outside a project archive. */ public function test_project_detail_is_silent_off_its_archive() { $this->go_to( home_url( '/' ) ); $this->assertSame( '', trim( do_blocks( '' ) ) ); } /** * Ensure a list card falls back to placeholder art when the stored cover * attachment no longer exists, instead of rendering a blank art column. */ public function test_project_list_with_deleted_cover_uses_placeholder_art() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'slug' => 'deleted-cover-list-test', ) ); update_term_meta( $term_id, 'chrnx_project_cover', 999999 ); $markup = do_blocks( '' ); // Scope the assertion to this term's own card: the taxonomy query is // unfiltered, so other projects' cards must not mask a broken one. $needle = 'chrnx_project=deleted-cover-list-test'; $link_offset = strpos( $markup, $needle ); $this->assertNotFalse( $link_offset, 'Expected a card linking to the test project.' ); $card_start = strrpos( substr( $markup, 0, $link_offset ), '', $link_offset ); $card = substr( $markup, $card_start, $card_end - $card_start ); $this->assertStringContainsString( 'chrnx-project-card__fallback', $card ); $this->assertStringNotContainsString( 'chrnx-project-card__cover', $card ); } /** * Ensure the detail block falls back to placeholder art when the stored * cover attachment no longer exists, instead of rendering a blank art column. */ public function test_project_detail_with_deleted_cover_uses_placeholder_art() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'slug' => 'deleted-cover-detail-test', ) ); update_term_meta( $term_id, 'chrnx_project_cover', 999999 ); $this->go_to( get_term_link( $term_id ) ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'chrnx-project-detail__fallback', $markup ); $this->assertStringNotContainsString( 'chrnx-project-detail__cover', $markup ); } /** * Ensure a project archive filters the journal to that project. */ public function test_project_archive_filters_the_journal() { $term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project', 'slug' => 'filter-test', ) ); $mine = self::factory()->post->create( array( 'post_title' => 'Belongs to the project' ) ); self::factory()->post->create( array( 'post_title' => 'Unrelated post' ) ); wp_set_object_terms( $mine, array( $term_id ), 'chrnx_project' ); $this->go_to( get_term_link( $term_id ) ); $markup = do_blocks( '' ); $this->assertStringContainsString( 'Belongs to the project', $markup ); $this->assertStringNotContainsString( 'Unrelated post', $markup ); } }