56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Tests for the project blocks.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
/**
|
|
* Verify project block rendering.
|
|
*/
|
|
class ProjectBlocksTest extends WP_UnitTestCase {
|
|
/**
|
|
* Register blocks and taxonomies before each test.
|
|
*/
|
|
public function set_up() {
|
|
parent::set_up();
|
|
do_action( 'init' );
|
|
}
|
|
|
|
/**
|
|
* Ensure the list renders one card per project with its status.
|
|
*/
|
|
public function test_project_list_renders_a_card_per_project() {
|
|
$term_id = self::factory()->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( '<!-- wp:chrnx/project-list /-->' );
|
|
|
|
$this->assertStringContainsString( 'chrnx-project-card', $markup );
|
|
$this->assertStringContainsString( 'Green Tea', $markup );
|
|
$this->assertStringContainsString( 'Beta', $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( '<!-- wp:chrnx/project-list /-->' );
|
|
|
|
$this->assertStringContainsString( 'chrnx-project-card__fallback', $markup );
|
|
}
|
|
}
|