Skip to content

Commit

Permalink
fixup rest-block-type-controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed Feb 22, 2021
1 parent 68a576b commit 4834b40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public function prepare_item_for_response( $block_type, $request ) {
'script',
'editor_style',
'style',
'variations',
);
foreach ( $extra_fields as $extra_field ) {
if ( rest_is_field_included( $extra_field, $fields ) ) {
Expand Down Expand Up @@ -638,7 +639,7 @@ public function get_item_schema() {
),
'readonly' => true,
'context' => array( 'embed', 'view', 'edit' ),
'default' => array(),
'default' => null,
),
'textdomain' => array(
'description' => __( 'Public text domain.' ),
Expand Down
5 changes: 4 additions & 1 deletion tests/phpunit/tests/rest-api/rest-block-type-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public function test_get_item_defaults() {
'render_callback' => false,
'textdomain' => false,
'example' => false,
'variations' => false,
);
register_block_type( $block_type, $settings );
wp_set_current_user( self::$admin_id );
Expand All @@ -301,6 +302,7 @@ public function test_get_item_defaults() {
$this->assertNull( $data['example'] );
$this->assertNull( $data['textdomain'] );
$this->assertFalse( $data['is_dynamic'] );
$this->assertSameSets( array(), $data['variations'] );
}

/**
Expand All @@ -312,7 +314,7 @@ public function test_get_item_schema() {
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
$this->assertCount( 20, $properties );
$this->assertCount( 21, $properties );
$this->assertArrayHasKey( 'api_version', $properties );
$this->assertArrayHasKey( 'title', $properties );
$this->assertArrayHasKey( 'icon', $properties );
Expand All @@ -333,6 +335,7 @@ public function test_get_item_schema() {
$this->assertArrayHasKey( 'example', $properties );
$this->assertArrayHasKey( 'uses_context', $properties );
$this->assertArrayHasKey( 'provides_context', $properties );
$this->assertArrayHasKey( 'variations', $properties );
}

/**
Expand Down

0 comments on commit 4834b40

Please sign in to comment.