Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Wire PHP tests for block editor settings #30984

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function gutenberg_get_default_block_categories() {
function gutenberg_get_block_categories( $editor_name_or_post ) {
// Assume the post editor when the WP_Post object passed.
$editor_name = is_object( $editor_name_or_post ) ? 'post-editor' : $editor_name_or_post;
$default_categories = get_default_block_categories();
$default_categories = gutenberg_get_default_block_categories();

/**
* Filters the default array of categories for block types.
Expand Down
13 changes: 8 additions & 5 deletions phpunit/block-editor.php → phpunit/block-editor-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ function test_get_allowed_block_types_deprecated_filter_post_editor() {
function test_get_default_block_editor_settings() {
$settings = gutenberg_get_default_block_editor_settings();

$this->assertCount( 16, $settings );
$this->assertCount( 17, $settings );
$this->assertTrue( $settings['__unstableEnableFullSiteEditingBlocks'] );
$this->assertFalse( $settings['alignWide'] );
$this->assertInternalType( 'array', $settings['allowedMimeTypes'] );
$this->assertTrue( $settings['allowedBlockTypes'] );
Expand Down Expand Up @@ -243,7 +244,7 @@ function test_get_default_block_editor_settings() {
*/
function test_get_block_editor_settings_returns_default_settings() {
$this->assertSameSets(
gutenberg_get_block_editor_settings( 'post-editor' ),
gutenberg_get_block_editor_settings( 'my-editor' ),
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
gutenberg_get_default_block_editor_settings()
);
}
Expand Down Expand Up @@ -274,7 +275,7 @@ function filter_block_editor_settings_my_editor( $editor_settings ) {
add_filter( 'block_categories_my-editor', 'filter_block_categories_my_editor', 10, 1 );
add_filter( 'block_editor_settings_my-editor', 'filter_block_editor_settings_my_editor', 10, 1 );

$settings = get_block_editor_settings( 'my-editor' );
$settings = gutenberg_get_block_editor_settings( 'my-editor' );

remove_filter( 'allowed_block_types_my-editor', 'filter_allowed_block_types_my_editor' );
remove_filter( 'block_categories_my-editor', 'filter_block_categories_my_editor' );
Expand All @@ -296,12 +297,14 @@ function filter_block_editor_settings_my_editor( $editor_settings ) {

/**
* @ticket 52920
* @expectedDeprecated block_categories
* @expectedDeprecated block_editor_settings
*/
function test_get_block_editor_settings_deprecated_filter_post_editor() {
add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), 10, 2 );
// This filter needs to run last to account for other filters registered in the plugin.
add_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ), PHP_INT_MAX, 2 );

$settings = get_block_editor_settings( 'post-editor' );
$settings = gutenberg_get_block_editor_settings( 'post-editor' );

remove_filter( 'block_editor_settings', array( $this, 'filter_set_block_editor_settings_post' ) );

Expand Down