mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
Add fields to WP_Block_Type
As part of #47620 and the RFC for block registeration. Server registered blocks are missing some fields. These changeset includes them. Props spacedmonkey, aduth. Fixes #48529. git-svn-id: https://develop.svn.wordpress.org/trunk@47875 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -825,6 +825,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
function test_get_block_editor_server_block_settings() {
|
||||
$name = 'core/test';
|
||||
$settings = array(
|
||||
'category' => 'common',
|
||||
'icon' => 'text',
|
||||
'render_callback' => 'foo',
|
||||
);
|
||||
@@ -836,7 +837,15 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
unregister_block_type( $name );
|
||||
|
||||
$this->assertArrayHasKey( $name, $blocks );
|
||||
$this->assertSame( array( 'icon' => 'text' ), $blocks[ $name ] );
|
||||
$this->assertEquals( array(
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'category' => 'common',
|
||||
'icon' => 'text',
|
||||
'keywords' => array(),
|
||||
'supports' => array(),
|
||||
'styles' => array(),
|
||||
), $blocks[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -349,6 +349,31 @@ class WP_Test_Block_Type extends WP_UnitTestCase {
|
||||
return json_encode( $attributes );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 48529
|
||||
*/
|
||||
public function test_register_block() {
|
||||
$block_type = new WP_Block_Type( 'core/fake', array(
|
||||
'title' => 'Test title',
|
||||
'category' => 'Test category',
|
||||
'parent' => array( 'core/third-party' ),
|
||||
'icon' => 'icon.png',
|
||||
'description' => 'test description',
|
||||
'keywords' => array( 'test keyword' ),
|
||||
'textdomain' => 'test_domain',
|
||||
'supports' => array( 'alignment' => true ),
|
||||
) );
|
||||
|
||||
$this->assertSame( 'Test title', $block_type->title );
|
||||
$this->assertSame( 'Test category', $block_type->category );
|
||||
$this->assertEqualSets( array( 'core/third-party' ), $block_type->parent );
|
||||
$this->assertSame( 'icon.png', $block_type->icon );
|
||||
$this->assertSame( 'test description', $block_type->description );
|
||||
$this->assertEqualSets( array( 'test keyword' ), $block_type->keywords );
|
||||
$this->assertSame( 'test_domain', $block_type->textdomain );
|
||||
$this->assertEqualSets( array( 'alignment' => true ), $block_type->supports );
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing the block version.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user