Skip to content

Commit

Permalink
Navigation Block: Verify that content is not removed when renaming th…
Browse files Browse the repository at this point in the history
…e nav menu (WordPress#60189)

Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
  • Loading branch information
3 people authored and cbravobernal committed Apr 9, 2024
1 parent 9c88c81 commit 080da62
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions phpunit/blocks/block-navigation-block-hooks-test.php
Expand Up @@ -122,4 +122,39 @@ public function test_block_core_navigation_dont_modify_no_post_id() {
'Post content did not match the original markup.'
);
}

/**
* @covers ::gutenberg_block_core_navigation_update_ignore_hooked_blocks_meta
*/
public function test_block_core_navigation_retains_content_if_not_set() {
if ( ! function_exists( 'set_ignored_hooked_blocks_metadata' ) ) {
$this->markTestSkipped( 'Test skipped on WordPress versions that do not included required Block Hooks functionality.' );
}

register_block_type(
'tests/my-block',
array(
'block_hooks' => array(
'core/navigation' => 'last_child',
),
)
);

$post = new stdClass();
$post->ID = self::$navigation_post->ID;
$post->post_title = 'Navigation Menu with changes';

$post = gutenberg_block_core_navigation_update_ignore_hooked_blocks_meta( $post );

$this->assertSame(
'Navigation Menu with changes',
$post->post_title,
'Post title was changed.'
);

$this->assertFalse(
isset( $post->post_content ),
'Post content should not be set.'
);
}
}

0 comments on commit 080da62

Please sign in to comment.