Skip to content

Commit 2c20b78

Browse files
committed
Add tests
1 parent 1bed0f2 commit 2c20b78

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

plugin/tests/phpunit/php/class-test-block-types.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,22 @@ function( $block ) {
8484
}
8585
);
8686

87+
set_theme_mod( 'text_style', 'elevated' );
88+
set_theme_mod( 'card_style', 'outlined' );
89+
8790
$block_types->register_blocks();
8891

8992
$blocks = \WP_Block_Type_Registry::get_instance()->get_all_registered();
9093

94+
$card_blocks = [
95+
'card',
96+
'cards-collection',
97+
'recent-posts',
98+
];
99+
91100
array_walk(
92101
self::$blocks,
93-
function( $block_name ) use ( $blocks ) {
102+
function( $block_name ) use ( $blocks, $card_blocks ) {
94103
// Assert the block is registered.
95104
$this->assertTrue( array_key_exists( 'material/' . $block_name, $blocks ) );
96105

@@ -103,6 +112,10 @@ function( $block_name ) use ( $blocks ) {
103112
$block_json = $block_folder . '/block.json';
104113
$metadata = json_decode( file_get_contents( $block_json ), true ); // phpcs:ignore
105114

115+
// We have set outlined to true for card blocks.
116+
if ( in_array( $block_name, $card_blocks, true ) ) {
117+
$metadata['attributes']['outlined']['default'] = true;
118+
}
106119
$this->assertEquals( $metadata['category'], $block->category );
107120
$this->assertEquals( $metadata['attributes'], $block->attributes );
108121

@@ -137,6 +150,7 @@ public function test_enqueue_block_editor_assets() {
137150

138151
// Assert inline js vars contains ajax url data.
139152
$this->assertRegexp( '/ajax_url/', $inline_js );
153+
$this->assertRegexp( '/globalStyle/', $inline_js );
140154
}
141155

142156
/**

0 commit comments

Comments
 (0)