Make WordPress Core


Ignore:
Timestamp:
11/12/2018 02:26:18 AM (5 years ago)
Author:
pento
Message:

Block Editor: Update @wordpress dependencies to the latest version.

Changes of note:

  • Includes the new Annotations API package.
  • wp-polyfill-ecmascript.js is renamed to wp-polyfill.js.
  • strip_dynamic_blocks() has been removed in favour of excerpt_remove_blocks().
  • The PHP block parser is now syncing from the block-serialization-default-parser package.
  • do_blocks() uses the new parser.
  • The do_block filter has been removed from do_blocks(), in favour of a render_block filter in render_block().

See #45145, #45190, #45264, #45282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/tests/phpunit/tests/blocks/render.php

    r43881 r43884  
    4747            $registry->unregister( 'core/test' );
    4848        }
     49        if ( $registry->is_registered( 'core/dynamic' ) ) {
     50            $registry->unregister( 'core/dynamic' );
     51        }
    4952    }
    5053
     
    7679        $block_filtered_content = preg_replace( "/\n{2,}/", "\n", $block_filtered_content );
    7780
     81        remove_shortcode( 'someshortcode' );
     82
    7883        $this->assertEquals( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
    7984    }
     
    8186    function handle_shortcode( $atts, $content ) {
    8287        return $content;
     88    }
     89
     90    public function test_can_nest_at_least_so_deep() {
     91        $minimum_depth = 99;
     92
     93        $content = 'deep inside';
     94        for ( $i = 0; $i < $minimum_depth; $i++ ) {
     95            $content = '<!-- wp:core/test -->' . $content . '<!-- /wp:core/test -->';
     96        }
     97
     98        $this->assertEquals( 'deep inside', do_blocks( $content ) );
     99    }
     100
     101    public function test_can_nest_at_least_so_deep_with_dynamic_blocks() {
     102        $minimum_depth = 99;
     103
     104        $content = '0';
     105        for ( $i = 0; $i < $minimum_depth; $i++ ) {
     106            $content = '<!-- wp:core/test -->' . $content . '<!-- /wp:core/test -->';
     107        }
     108
     109        register_block_type(
     110            'core/test',
     111            array(
     112                'render_callback' => array(
     113                    $this,
     114                    'render_dynamic_incrementer',
     115                ),
     116            )
     117        );
     118
     119        $this->assertEquals( $minimum_depth, (int) do_blocks( $content ) );
     120    }
     121
     122    public function render_dynamic_incrementer( $attrs, $content ) {
     123        return (string) ( 1 + (int) $content );
    83124    }
    84125
     
    243284    }
    244285
     286    public function test_dynamic_block_gets_inner_html() {
     287        register_block_type(
     288            'core/dynamic',
     289            array(
     290                'render_callback' => array(
     291                    $this,
     292                    'render_serialize_dynamic_block',
     293                ),
     294            )
     295        );
     296
     297        $output = do_blocks( '<!-- wp:dynamic -->inner<!-- /wp:dynamic -->' );
     298
     299        $data = unserialize( base64_decode( $output ) );
     300
     301        $this->assertEquals( 'inner', $data[1] );
     302    }
     303
     304    public function test_dynamic_block_gets_rendered_inner_blocks() {
     305        register_block_type(
     306            'core/test',
     307            array(
     308                'render_callback' => array(
     309                    $this,
     310                    'render_test_block_numeric',
     311                ),
     312            )
     313        );
     314
     315        register_block_type(
     316            'core/dynamic',
     317            array(
     318                'render_callback' => array(
     319                    $this,
     320                    'render_serialize_dynamic_block',
     321                ),
     322            )
     323        );
     324
     325        $output = do_blocks( '<!-- wp:dynamic -->before<!-- wp:test /-->after<!-- /wp:dynamic -->' );
     326
     327        $data = unserialize( base64_decode( $output ) );
     328
     329        $this->assertEquals( 'before10after', $data[1] );
     330    }
     331
     332    public function test_dynamic_block_gets_rendered_inner_dynamic_blocks() {
     333        register_block_type(
     334            'core/dynamic',
     335            array(
     336                'render_callback' => array(
     337                    $this,
     338                    'render_serialize_dynamic_block',
     339                ),
     340            )
     341        );
     342
     343        $output = do_blocks( '<!-- wp:dynamic -->before<!-- wp:dynamic -->deep inner<!-- /wp:dynamic -->after<!-- /wp:dynamic -->' );
     344
     345        $data = unserialize( base64_decode( $output ) );
     346
     347        $inner = $this->render_serialize_dynamic_block( array(), 'deep inner' );
     348
     349        $this->assertEquals( $data[1], 'before' . $inner . 'after' );
     350    }
     351
    245352    /**
    246353     * Helper function to remove relative paths and extension from a filename, leaving just the fixture name.
     
    306413    public function render_test_block_numeric() {
    307414        return 10;
     415    }
     416
     417    /**
     418     * Test block rendering function, returning base64 encoded serialised value.
     419     *
     420     * @since 5.0.0
     421     *
     422     * @return string Block output.
     423     */
     424    public function render_serialize_dynamic_block( $attributes, $content ) {
     425        return base64_encode( serialize( array( $attributes, $content ) ) );
    308426    }
    309427
Note: See TracChangeset for help on using the changeset viewer.