diff --git a/phpunit/block-library/class-test-archives.php b/phpunit/block-library/class-test-archives.php new file mode 100644 index 0000000000000..00006cf09e340 --- /dev/null +++ b/phpunit/block-library/class-test-archives.php @@ -0,0 +1,71 @@ +post->create(); + } + + /** + * Verify the block output when no posts are found. + */ + public function test_no_posts_found() { + // The shared fixture is published, so modifying the SQL query used by `wp_get_archives()` will make it seem + // like there are no posts to show. + add_filter( + 'getarchives_where', + function( $sql_where ) { + return str_replace( 'publish', 'private', $sql_where ); + } + ); + + $this->assertDiscardWhitespace( + '
No archives to show.
', + render_block_core_archives( + array( + 'displayAsDropdown' => false, + 'showPostCounts' => false, + ) + ) + ); + } + + /** + * Verify the block classes with the default attributes. + */ + public function test_default_block_classes_output() { + $this->assertContains( + '