diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 2ec3a07e3e..98d8f10d5c 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -112,3 +112,40 @@ function get_dynamic_block_names() { return $dynamic_block_names; } + +/** + * Parses blocks out of a content string. + * + * @since 5.0.0 + * + * @param string $content Post content. + * @return array Array of parsed block objects. + */ +function parse_blocks( $content ) { + /* + * If there are no blocks in the content, return a single block, rather + * than wasting time trying to parse the string. + */ + if ( ! has_blocks( $content ) ) { + return array( + array( + 'blockName' => null, + 'attrs' => array(), + 'innerBlocks' => array(), + 'innerHTML' => $content, + ), + ); + } + + /** + * Filter to allow plugins to replace the server-side block parser + * + * @since 5.0.0 + * + * @param string $parser_class Name of block parser class + */ + $parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' ); + + $parser = new $parser_class(); + return $parser->parse( $content ); +} diff --git a/src/wp-includes/class-wp-block-parser.php b/src/wp-includes/class-wp-block-parser.php new file mode 100644 index 0000000000..78b6921787 --- /dev/null +++ b/src/wp-includes/class-wp-block-parser.php @@ -0,0 +1,473 @@ + 3 ) + * + * @since 3.8.0 + * @var array|null + */ + public $attrs; + + /** + * List of inner blocks (of this same class) + * + * @since 3.8.0 + * @var WP_Block_Parser_Block[] + */ + public $innerBlocks; + + /** + * Resultant HTML from inside block comment delimiters + * after removing inner blocks + * + * @example "...Just testing..." -> "Just testing..." + * + * @since 3.8.0 + * @var string + */ + public $innerHTML; + + function __construct( $name, $attrs, $innerBlocks, $innerHTML ) { + $this->blockName = $name; + $this->attrs = $attrs; + $this->innerBlocks = $innerBlocks; + $this->innerHTML = $innerHTML; + } +} + +/** + * Class WP_Block_Parser_Frame + * + * Holds partial blocks in memory while parsing + * + * @internal + * @since 3.8.0 + */ +class WP_Block_Parser_Frame { + /** + * Full or partial block + * + * @since 3.8.0 + * @var WP_Block_Parser_Block + */ + public $block; + + /** + * Byte offset into document for start of parse token + * + * @since 3.8.0 + * @var int + */ + public $token_start; + + /** + * Byte length of entire parse token string + * + * @since 3.8.0 + * @var int + */ + public $token_length; + + /** + * Byte offset into document for after parse token ends + * (used during reconstruction of stack into parse production) + * + * @since 3.8.0 + * @var int + */ + public $prev_offset; + + /** + * Byte offset into document where leading HTML before token starts + * + * @since 3.8.0 + * @var int + */ + public $leading_html_start; + + function __construct( $block, $token_start, $token_length, $prev_offset = null, $leading_html_start = null ) { + $this->block = $block; + $this->token_start = $token_start; + $this->token_length = $token_length; + $this->prev_offset = isset( $prev_offset ) ? $prev_offset : $token_start + $token_length; + $this->leading_html_start = $leading_html_start; + } +} + +/** + * Class WP_Block_Parser + * + * Parses a document and constructs a list of parsed block objects + * + * @since 3.8.0 + * @since 4.0.0 returns arrays not objects, all attributes are arrays + */ +class WP_Block_Parser { + /** + * Input document being parsed + * + * @example "Pre-text\nThis is inside a block!" + * + * @since 3.8.0 + * @var string + */ + public $document; + + /** + * Tracks parsing progress through document + * + * @since 3.8.0 + * @var int + */ + public $offset; + + /** + * List of parsed blocks + * + * @since 3.8.0 + * @var WP_Block_Parser_Block[] + */ + public $output; + + /** + * Stack of partially-parsed structures in memory during parse + * + * @since 3.8.0 + * @var WP_Block_Parser_Frame[] + */ + public $stack; + + /** + * Parses a document and returns a list of block structures + * + * When encountering an invalid parse will return a best-effort + * parse. In contrast to the specification parser this does not + * return an error on invalid inputs. + * + * @since 3.8.0 + * + * @param string $document + * @return WP_Block_Parser_Block[] + */ + function parse( $document ) { + $this->document = $document; + $this->offset = 0; + $this->output = array(); + $this->stack = array(); + + do { + // twiddle our thumbs + } while ( $this->proceed() ); + + return $this->output; + } + + /** + * Processes the next token from the input document + * and returns whether to proceed eating more tokens + * + * This is the "next step" function that essentially + * takes a token as its input and decides what to do + * with that token before descending deeper into a + * nested block tree or continuing along the document + * or breaking out of a level of nesting. + * + * @internal + * @since 3.8.0 + * @return bool + */ + function proceed() { + $next_token = $this->next_token(); + list( $token_type, $block_name, $attrs, $start_offset, $token_length ) = $next_token; + $stack_depth = count( $this->stack ); + + // we may have some HTML soup before the next block + $leading_html_start = $start_offset > $this->offset ? $this->offset : null; + + switch ( $token_type ) { + case 'no-more-tokens': + // if not in a block then flush output + if ( 0 === $stack_depth ) { + $this->add_freeform(); + return false; + } + + /* + * Otherwise we have a problem + * This is an error + * + * we have options + * - treat it all as freeform text + * - assume an implicit closer (easiest when not nesting) + */ + + // for the easy case we'll assume an implicit closer + if ( 1 === $stack_depth ) { + $this->add_block_from_stack(); + return false; + } + + /* + * for the nested case where it's more difficult we'll + * have to assume that multiple closers are missing + * and so we'll collapse the whole stack piecewise + */ + while ( 0 < count( $this->stack ) ) { + $this->add_block_from_stack(); + } + return false; + + case 'void-block': + /* + * easy case is if we stumbled upon a void block + * in the top-level of the document + */ + if ( 0 === $stack_depth ) { + if ( isset( $leading_html_start ) ) { + $this->output[] = (array) self::freeform( substr( + $this->document, + $leading_html_start, + $start_offset - $leading_html_start + ) ); + } + + $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ); + $this->offset = $start_offset + $token_length; + return true; + } + + // otherwise we found an inner block + $this->add_inner_block( + new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), + $start_offset, + $token_length + ); + $this->offset = $start_offset + $token_length; + return true; + + case 'block-opener': + // track all newly-opened blocks on the stack + array_push( $this->stack, new WP_Block_Parser_Frame( + new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), + $start_offset, + $token_length, + $start_offset + $token_length, + $leading_html_start + ) ); + $this->offset = $start_offset + $token_length; + return true; + + case 'block-closer': + /* + * if we're missing an opener we're in trouble + * This is an error + */ + if ( 0 === $stack_depth ) { + /* + * we have options + * - assume an implicit opener + * - assume _this_ is the opener + * - give up and close out the document + */ + $this->add_freeform(); + return false; + } + + // if we're not nesting then this is easy - close the block + if ( 1 === $stack_depth ) { + $this->add_block_from_stack( $start_offset ); + $this->offset = $start_offset + $token_length; + return true; + } + + /* + * otherwise we're nested and we have to close out the current + * block and add it as a new innerBlock to the parent + */ + $stack_top = array_pop( $this->stack ); + $stack_top->block->innerHTML .= substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); + $stack_top->prev_offset = $start_offset + $token_length; + + $this->add_inner_block( + $stack_top->block, + $stack_top->token_start, + $stack_top->token_length, + $start_offset + $token_length + ); + $this->offset = $start_offset + $token_length; + return true; + + default: + // This is an error + $this->add_freeform(); + return false; + } + } + + /** + * Scans the document from where we last left off + * and finds the next valid token to parse if it exists + * + * Returns the type of the find: kind of find, block information, attributes + * + * @internal + * @since 3.8.0 + * @return array + */ + function next_token() { + $matches = null; + + /* + * aye the magic + * we're using a single RegExp to tokenize the block comment delimiters + * we're also using a trick here because the only difference between a + * block opener and a block closer is the leading `/` before `wp:` (and + * a closer has no attributes). we can trap them both and process the + * match back in PHP to see which one it was. + */ + $has_match = preg_match( + '/).)+?}\s+)?(?\/)?-->/s', + $this->document, + $matches, + PREG_OFFSET_CAPTURE, + $this->offset + ); + + // we have no more tokens + if ( 0 === $has_match ) { + return array( 'no-more-tokens', null, null, null, null ); + } + + list( $match, $started_at ) = $matches[ 0 ]; + + $length = strlen( $match ); + $is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ]; + $is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ]; + $namespace = $matches[ 'namespace' ]; + $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/'; + $name = $namespace . $matches[ 'name' ][ 0 ]; + $has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ]; + + /* + * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays + * are associative arrays. If we use `array()` we get a JSON `[]` + */ + $attrs = $has_attrs + ? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true ) + : json_decode( '{}', /* don't ask why, just verify in PHP */ false ); + + /* + * This state isn't allowed + * This is an error + */ + if ( $is_closer && ( $is_void || $has_attrs ) ) { + // we can ignore them since they don't hurt anything + } + + if ( $is_void ) { + return array( 'void-block', $name, $attrs, $started_at, $length ); + } + + if ( $is_closer ) { + return array( 'block-closer', $name, null, $started_at, $length ); + } + + return array( 'block-opener', $name, $attrs, $started_at, $length ); + } + + /** + * Returns a new block object for freeform HTML + * + * @internal + * @since 3.9.0 + * + * @param string $innerHTML HTML content of block + * @return WP_Block_Parser_Block freeform block object + */ + static function freeform( $innerHTML ) { + return new WP_Block_Parser_Block( null, array(), array(), $innerHTML ); + } + + /** + * Pushes a length of text from the input document + * to the output list as a freeform block + * + * @internal + * @since 3.8.0 + * @param null $length how many bytes of document text to output + */ + function add_freeform( $length = null ) { + $length = $length ? $length : strlen( $this->document ) - $this->offset; + + if ( 0 === $length ) { + return; + } + + $this->output[] = (array) self::freeform( substr( $this->document, $this->offset, $length ) ); + } + + /** + * Given a block structure from memory pushes + * a new block to the output list + * + * @internal + * @since 3.8.0 + * @param WP_Block_Parser_Block $block the block to add to the output + * @param int $token_start byte offset into the document where the first token for the block starts + * @param int $token_length byte length of entire block from start of opening token to end of closing token + * @param int|null $last_offset last byte offset into document if continuing form earlier output + */ + function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { + $parent = $this->stack[ count( $this->stack ) - 1 ]; + $parent->block->innerBlocks[] = $block; + $parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); + $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; + } + + /** + * Pushes the top block from the parsing stack to the output list + * + * @internal + * @since 3.8.0 + * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML + */ + function add_block_from_stack( $end_offset = null ) { + $stack_top = array_pop( $this->stack ); + $prev_offset = $stack_top->prev_offset; + + $stack_top->block->innerHTML .= isset( $end_offset ) + ? substr( $this->document, $prev_offset, $end_offset - $prev_offset ) + : substr( $this->document, $prev_offset ); + + if ( isset( $stack_top->leading_html_start ) ) { + $this->output[] = (array) self::freeform( substr( + $this->document, + $stack_top->leading_html_start, + $stack_top->token_start - $stack_top->leading_html_start + ) ); + } + + $this->output[] = (array) $stack_top->block; + } +} diff --git a/src/wp-settings.php b/src/wp-settings.php index 4ae30df9ca..fbd231d45a 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -246,6 +246,7 @@ require( ABSPATH . WPINC . '/rest-api/search/class-wp-rest-search-handler.php' ) require( ABSPATH . WPINC . '/rest-api/search/class-wp-rest-post-search-handler.php' ); require( ABSPATH . WPINC . '/class-wp-block-type.php' ); require( ABSPATH . WPINC . '/class-wp-block-type-registry.php' ); +require( ABSPATH . WPINC . '/class-wp-block-parser.php' ); require( ABSPATH . WPINC . '/blocks.php' ); $GLOBALS['wp_embed'] = new WP_Embed(); diff --git a/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.html b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.html new file mode 100644 index 0000000000..220f8b60c8 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.json b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.json new file mode 100644 index 0000000000..3439923f41 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/freeform", + "isValid": true, + "attributes": { + "content": "

" + }, + "innerBlocks": [], + "originalContent": "

" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.parsed.json b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.parsed.json new file mode 100644 index 0000000000..2dfce101b4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.parsed.json @@ -0,0 +1,8 @@ +[ + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.serialized.html b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.serialized.html new file mode 100644 index 0000000000..fe35001a46 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__4-invalid-starting-letter.serialized.html @@ -0,0 +1 @@ +

diff --git a/tests/phpunit/data/blocks/fixtures/core__archives.html b/tests/phpunit/data/blocks/fixtures/core__archives.html new file mode 100644 index 0000000000..dbed6fec17 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/phpunit/data/blocks/fixtures/core__archives.json b/tests/phpunit/data/blocks/fixtures/core__archives.json new file mode 100644 index 0000000000..ad43f4051a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/archives", + "isValid": true, + "attributes": { + "displayAsDropdown": false, + "showPostCounts": false + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__archives.parsed.json b/tests/phpunit/data/blocks/fixtures/core__archives.parsed.json new file mode 100644 index 0000000000..fab690ff93 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives.parsed.json @@ -0,0 +1,11 @@ +[ + { + "blockName": "core/archives", + "attrs": { + "displayAsDropdown": false, + "showPostCounts": false + }, + "innerBlocks": [], + "innerHTML": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__archives.serialized.html b/tests/phpunit/data/blocks/fixtures/core__archives.serialized.html new file mode 100644 index 0000000000..b892875237 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.html b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.html new file mode 100644 index 0000000000..cce02a6a1a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.json b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.json new file mode 100644 index 0000000000..0c1514e413 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/archives", + "isValid": true, + "attributes": { + "displayAsDropdown": false, + "showPostCounts": true + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.parsed.json b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.parsed.json new file mode 100644 index 0000000000..cd58cbf969 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.parsed.json @@ -0,0 +1,11 @@ +[ + { + "blockName": "core/archives", + "attrs": { + "displayAsDropdown": false, + "showPostCounts": true + }, + "innerBlocks": [], + "innerHTML": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.serialized.html b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.serialized.html new file mode 100644 index 0000000000..e294016710 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__archives__showPostCounts.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__audio.html b/tests/phpunit/data/blocks/fixtures/core__audio.html new file mode 100644 index 0000000000..cfa3f20267 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__audio.html @@ -0,0 +1,5 @@ + +
+ +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__audio.json b/tests/phpunit/data/blocks/fixtures/core__audio.json new file mode 100644 index 0000000000..f9acbfdd8c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__audio.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/audio", + "isValid": true, + "attributes": { + "src": "https://media.simplecast.com/episodes/audio/80564/draft-podcast-51-livePublish2.mp3", + "caption": "", + "autoplay": false, + "loop": false, + "align": "right" + }, + "innerBlocks": [], + "originalContent": "
\n \n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__audio.parsed.json b/tests/phpunit/data/blocks/fixtures/core__audio.parsed.json new file mode 100644 index 0000000000..33926c0b88 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__audio.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/audio", + "attrs": { + "align": "right" + }, + "innerBlocks": [], + "innerHTML": "\n
\n \n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__audio.serialized.html b/tests/phpunit/data/blocks/fixtures/core__audio.serialized.html new file mode 100644 index 0000000000..f7b69332aa --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__audio.serialized.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__block.html b/tests/phpunit/data/blocks/fixtures/core__block.html new file mode 100644 index 0000000000..25cde6619b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__block.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__block.json b/tests/phpunit/data/blocks/fixtures/core__block.json new file mode 100644 index 0000000000..da89e970b4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__block.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/block", + "isValid": true, + "attributes": { + "ref": 123 + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__block.parsed.json b/tests/phpunit/data/blocks/fixtures/core__block.parsed.json new file mode 100644 index 0000000000..61b65e317a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__block.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/block", + "attrs": { + "ref": 123 + }, + "innerBlocks": [], + "innerHTML": "" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__block.serialized.html b/tests/phpunit/data/blocks/fixtures/core__block.serialized.html new file mode 100644 index 0000000000..65efadb46d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__block.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__button__center.html b/tests/phpunit/data/blocks/fixtures/core__button__center.html new file mode 100644 index 0000000000..ce1262f706 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__button__center.html @@ -0,0 +1,3 @@ + +
Help build Gutenberg
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__button__center.json b/tests/phpunit/data/blocks/fixtures/core__button__center.json new file mode 100644 index 0000000000..7334b3f483 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__button__center.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/button", + "isValid": true, + "attributes": { + "url": "https://github.com/WordPress/gutenberg", + "text": "Help build Gutenberg", + "align": "center" + }, + "innerBlocks": [], + "originalContent": "
Help build Gutenberg
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__button__center.parsed.json b/tests/phpunit/data/blocks/fixtures/core__button__center.parsed.json new file mode 100644 index 0000000000..0094e8f264 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__button__center.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/button", + "attrs": { + "align": "center" + }, + "innerBlocks": [], + "innerHTML": "\n
Help build Gutenberg
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__button__center.serialized.html b/tests/phpunit/data/blocks/fixtures/core__button__center.serialized.html new file mode 100644 index 0000000000..3d88c7ec1a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__button__center.serialized.html @@ -0,0 +1,3 @@ + +
Help build Gutenberg
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__categories.html b/tests/phpunit/data/blocks/fixtures/core__categories.html new file mode 100644 index 0000000000..89dd1be4ab --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__categories.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__categories.json b/tests/phpunit/data/blocks/fixtures/core__categories.json new file mode 100644 index 0000000000..ff93919fbc --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__categories.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/categories", + "isValid": true, + "attributes": { + "showPostCounts": false, + "displayAsDropdown": false, + "showHierarchy": false + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__categories.parsed.json b/tests/phpunit/data/blocks/fixtures/core__categories.parsed.json new file mode 100644 index 0000000000..df39a8078d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__categories.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/categories", + "attrs": { + "showPostCounts": false, + "displayAsDropdown": false, + "showHierarchy": false + }, + "innerBlocks": [], + "innerHTML": "" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__categories.serialized.html b/tests/phpunit/data/blocks/fixtures/core__categories.serialized.html new file mode 100644 index 0000000000..7816d6b192 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__categories.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__code.html b/tests/phpunit/data/blocks/fixtures/core__code.html new file mode 100644 index 0000000000..5d3f951c17 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__code.html @@ -0,0 +1,5 @@ + +
export default function MyButton() {
+	return <Button>Click Me!</Button>;
+}
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__code.json b/tests/phpunit/data/blocks/fixtures/core__code.json new file mode 100644 index 0000000000..0958025736 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__code.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/code", + "isValid": true, + "attributes": { + "content": "export default function MyButton() {\n\treturn ;\n}" + }, + "innerBlocks": [], + "originalContent": "
export default function MyButton() {\n\treturn <Button>Click Me!</Button>;\n}
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__code.parsed.json b/tests/phpunit/data/blocks/fixtures/core__code.parsed.json new file mode 100644 index 0000000000..5aea1d9a14 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__code.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/code", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
export default function MyButton() {\n\treturn <Button>Click Me!</Button>;\n}
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__code.serialized.html b/tests/phpunit/data/blocks/fixtures/core__code.serialized.html new file mode 100644 index 0000000000..651254a7ca --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__code.serialized.html @@ -0,0 +1,5 @@ + +
export default function MyButton() {
+	return <Button>Click Me!</Button>;
+}
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__column.html b/tests/phpunit/data/blocks/fixtures/core__column.html new file mode 100644 index 0000000000..a18d2ee30a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__column.html @@ -0,0 +1,10 @@ + +
+ +

Column One, Paragraph One

+ + +

Column One, Paragraph Two

+ +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__column.json b/tests/phpunit/data/blocks/fixtures/core__column.json new file mode 100644 index 0000000000..aabfc10300 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__column.json @@ -0,0 +1,33 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/column", + "isValid": true, + "attributes": {}, + "innerBlocks": [ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column One, Paragraph One", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column One, Paragraph One

" + }, + { + "clientId": "_clientId_1", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column One, Paragraph Two", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column One, Paragraph Two

" + } + ], + "originalContent": "
\n\t\n\t\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__column.parsed.json b/tests/phpunit/data/blocks/fixtures/core__column.parsed.json new file mode 100644 index 0000000000..74b53bdf6a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__column.parsed.json @@ -0,0 +1,27 @@ +[ + { + "blockName": "core/column", + "attrs": {}, + "innerBlocks": [ + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t

Column One, Paragraph One

\n\t" + }, + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t

Column One, Paragraph Two

\n\t" + } + ], + "innerHTML": "\n
\n\t\n\t\n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__column.serialized.html b/tests/phpunit/data/blocks/fixtures/core__column.serialized.html new file mode 100644 index 0000000000..5d7839c470 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__column.serialized.html @@ -0,0 +1,9 @@ + +
+

Column One, Paragraph One

+ + + +

Column One, Paragraph Two

+
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__columns.html b/tests/phpunit/data/blocks/fixtures/core__columns.html new file mode 100644 index 0000000000..bcced4e7b9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__columns.html @@ -0,0 +1,24 @@ + +
+ +
+ +

Column One, Paragraph One

+ + +

Column One, Paragraph Two

+ +
+ + +
+ +

Column Two, Paragraph One

+ + +

Column Three, Paragraph One

+ +
+ +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__columns.json b/tests/phpunit/data/blocks/fixtures/core__columns.json new file mode 100644 index 0000000000..2a446b72dc --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__columns.json @@ -0,0 +1,75 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/columns", + "isValid": true, + "attributes": { + "columns": 3 + }, + "innerBlocks": [ + { + "clientId": "_clientId_0", + "name": "core/column", + "isValid": true, + "attributes": {}, + "innerBlocks": [ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column One, Paragraph One", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column One, Paragraph One

" + }, + { + "clientId": "_clientId_1", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column One, Paragraph Two", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column One, Paragraph Two

" + } + ], + "originalContent": "
\n\t\t\n\t\t\n\t
" + }, + { + "clientId": "_clientId_1", + "name": "core/column", + "isValid": true, + "attributes": {}, + "innerBlocks": [ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column Two, Paragraph One", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column Two, Paragraph One

" + }, + { + "clientId": "_clientId_1", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column Three, Paragraph One", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column Three, Paragraph One

" + } + ], + "originalContent": "
\n\t\t\n\t\t\n\t
" + } + ], + "originalContent": "
\n\t\n\t\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__columns.parsed.json b/tests/phpunit/data/blocks/fixtures/core__columns.parsed.json new file mode 100644 index 0000000000..9ec5cef66a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__columns.parsed.json @@ -0,0 +1,55 @@ +[ + { + "blockName": "core/columns", + "attrs": { + "columns": 3 + }, + "innerBlocks": [ + { + "blockName": "core/column", + "attrs": {}, + "innerBlocks": [ + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t\t

Column One, Paragraph One

\n\t\t" + }, + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t\t

Column One, Paragraph Two

\n\t\t" + } + ], + "innerHTML": "\n\t
\n\t\t\n\t\t\n\t
\n\t" + }, + { + "blockName": "core/column", + "attrs": {}, + "innerBlocks": [ + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t\t

Column Two, Paragraph One

\n\t\t" + }, + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t\t

Column Three, Paragraph One

\n\t\t" + } + ], + "innerHTML": "\n\t
\n\t\t\n\t\t\n\t
\n\t" + } + ], + "innerHTML": "\n
\n\t\n\t\n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__columns.serialized.html b/tests/phpunit/data/blocks/fixtures/core__columns.serialized.html new file mode 100644 index 0000000000..b7472ac094 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__columns.serialized.html @@ -0,0 +1,21 @@ + +
+
+

Column One, Paragraph One

+ + + +

Column One, Paragraph Two

+
+ + + +
+

Column Two, Paragraph One

+ + + +

Column Three, Paragraph One

+
+
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__cover-image.html b/tests/phpunit/data/blocks/fixtures/core__cover-image.html new file mode 100644 index 0000000000..86b5915701 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__cover-image.html @@ -0,0 +1,5 @@ + +
+

Guten Berg!

+
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__cover-image.json b/tests/phpunit/data/blocks/fixtures/core__cover-image.json new file mode 100644 index 0000000000..342a160d3e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__cover-image.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/cover-image", + "isValid": true, + "attributes": { + "title": "Guten Berg!", + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "contentAlign": "center", + "hasParallax": false, + "dimRatio": 40 + }, + "innerBlocks": [], + "originalContent": "
\n

Guten Berg!

\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__cover-image.parsed.json b/tests/phpunit/data/blocks/fixtures/core__cover-image.parsed.json new file mode 100644 index 0000000000..93bc4fbc8d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__cover-image.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/cover-image", + "attrs": { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "dimRatio": 40 + }, + "innerBlocks": [], + "innerHTML": "\n
\n

Guten Berg!

\n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__cover-image.serialized.html b/tests/phpunit/data/blocks/fixtures/core__cover-image.serialized.html new file mode 100644 index 0000000000..d64692d60c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__cover-image.serialized.html @@ -0,0 +1,3 @@ + +

Guten Berg!

+ diff --git a/tests/phpunit/data/blocks/fixtures/core__embed.html b/tests/phpunit/data/blocks/fixtures/core__embed.html new file mode 100644 index 0000000000..211e9e114e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__embed.html @@ -0,0 +1,8 @@ + +
+
+ https://example.com/ +
+
Embedded content from an example URL
+
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__embed.json b/tests/phpunit/data/blocks/fixtures/core__embed.json new file mode 100644 index 0000000000..916935db4c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__embed.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/embed", + "isValid": true, + "attributes": { + "url": "https://example.com/", + "caption": "Embedded content from an example URL", + "allowResponsive": true + }, + "innerBlocks": [], + "originalContent": "
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__embed.parsed.json b/tests/phpunit/data/blocks/fixtures/core__embed.parsed.json new file mode 100644 index 0000000000..5efa23bb5f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__embed.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/embed", + "attrs": { + "url": "https://example.com/" + }, + "innerBlocks": [], + "innerHTML": "\n
\n
\n https://example.com/\n
\n
Embedded content from an example URL
\n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__embed.serialized.html b/tests/phpunit/data/blocks/fixtures/core__embed.serialized.html new file mode 100644 index 0000000000..3906dd45ee --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__embed.serialized.html @@ -0,0 +1,5 @@ + +
+https://example.com/ +
Embedded content from an example URL
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__new-window.html b/tests/phpunit/data/blocks/fixtures/core__file__new-window.html new file mode 100644 index 0000000000..e8ee1b8258 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__new-window.html @@ -0,0 +1,3 @@ + +
6546Download
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__new-window.json b/tests/phpunit/data/blocks/fixtures/core__file__new-window.json new file mode 100644 index 0000000000..4922f02880 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__new-window.json @@ -0,0 +1,18 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/file", + "isValid": true, + "attributes": { + "id": 176, + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "fileName": "6546", + "textLinkHref": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "textLinkTarget": "_blank", + "showDownloadButton": true, + "downloadButtonText": "Download" + }, + "innerBlocks": [], + "originalContent": "
6546Download
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__new-window.parsed.json b/tests/phpunit/data/blocks/fixtures/core__file__new-window.parsed.json new file mode 100644 index 0000000000..481c7e5c98 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__new-window.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/file", + "attrs": { + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "showDownloadButton": true, + "id": 176 + }, + "innerBlocks": [], + "innerHTML": "\n
6546Download
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__new-window.serialized.html b/tests/phpunit/data/blocks/fixtures/core__file__new-window.serialized.html new file mode 100644 index 0000000000..7d28f4db58 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__new-window.serialized.html @@ -0,0 +1,3 @@ + +
6546Download
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.html b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.html new file mode 100644 index 0000000000..54d82d4391 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.html @@ -0,0 +1,3 @@ + +
lkjfijwef
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.json b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.json new file mode 100644 index 0000000000..44ff5553ac --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.json @@ -0,0 +1,17 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/file", + "isValid": true, + "attributes": { + "id": 176, + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "fileName": "lkjfijwef", + "textLinkHref": "http://localhost:8888/?attachment_id=176", + "showDownloadButton": false, + "downloadButtonText": "" + }, + "innerBlocks": [], + "originalContent": "
lkjfijwef
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.parsed.json b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.parsed.json new file mode 100644 index 0000000000..65a2cffa5e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/file", + "attrs": { + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "showDownloadButton": false, + "id": 176 + }, + "innerBlocks": [], + "innerHTML": "\n
lkjfijwef
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.serialized.html b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.serialized.html new file mode 100644 index 0000000000..639e3e6c9d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-download-button.serialized.html @@ -0,0 +1,3 @@ + +
lkjfijwef
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.html b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.html new file mode 100644 index 0000000000..89c0390aac --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.html @@ -0,0 +1,3 @@ + +
Download
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.json b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.json new file mode 100644 index 0000000000..6cf32d1f9d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/file", + "isValid": true, + "attributes": { + "id": 176, + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "fileName": "", + "showDownloadButton": true, + "downloadButtonText": "Download" + }, + "innerBlocks": [], + "originalContent": "
Download
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.parsed.json b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.parsed.json new file mode 100644 index 0000000000..c905766eb9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/file", + "attrs": { + "href": "http://localhost:8888/wp-content/uploads/2018/05/keycodes.js", + "showDownloadButton": true, + "id": 176 + }, + "innerBlocks": [], + "innerHTML": "\n
Download
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.serialized.html b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.serialized.html new file mode 100644 index 0000000000..a0ab5b5f41 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__file__no-text-link.serialized.html @@ -0,0 +1,3 @@ + +
Download
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform.html b/tests/phpunit/data/blocks/fixtures/core__freeform.html new file mode 100644 index 0000000000..302e94487b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform.html @@ -0,0 +1,6 @@ + +Testing freeform block with some +
+ HTML content +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform.json b/tests/phpunit/data/blocks/fixtures/core__freeform.json new file mode 100644 index 0000000000..72341f093f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/freeform", + "isValid": true, + "attributes": { + "content": "

Testing freeform block with some\n

\n\tHTML content\n
" + }, + "innerBlocks": [], + "originalContent": "

Testing freeform block with some\n

\n\tHTML content\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform.parsed.json b/tests/phpunit/data/blocks/fixtures/core__freeform.parsed.json new file mode 100644 index 0000000000..5cf330c0e9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/freeform", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\nTesting freeform block with some\n
\n\tHTML content\n
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform.serialized.html b/tests/phpunit/data/blocks/fixtures/core__freeform.serialized.html new file mode 100644 index 0000000000..4fed04550b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform.serialized.html @@ -0,0 +1,4 @@ +

Testing freeform block with some +

+ HTML content +
diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.html b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.html new file mode 100644 index 0000000000..2c349303c5 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.html @@ -0,0 +1,4 @@ +Testing freeform block with some +
+ HTML content +
diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.json b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.json new file mode 100644 index 0000000000..72341f093f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/freeform", + "isValid": true, + "attributes": { + "content": "

Testing freeform block with some\n

\n\tHTML content\n
" + }, + "innerBlocks": [], + "originalContent": "

Testing freeform block with some\n

\n\tHTML content\n
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.parsed.json b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.parsed.json new file mode 100644 index 0000000000..e0b2c76f29 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.parsed.json @@ -0,0 +1,8 @@ +[ + { + "attrs": {}, + "blockName": null, + "innerBlocks": [], + "innerHTML": "Testing freeform block with some\n
\n\tHTML content\n
\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.serialized.html b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.serialized.html new file mode 100644 index 0000000000..4fed04550b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__freeform__undelimited.serialized.html @@ -0,0 +1,4 @@ +

Testing freeform block with some +

+ HTML content +
diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery.html b/tests/phpunit/data/blocks/fixtures/core__gallery.html new file mode 100644 index 0000000000..5e48c7e663 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery.html @@ -0,0 +1,14 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery.json b/tests/phpunit/data/blocks/fixtures/core__gallery.json new file mode 100644 index 0000000000..8cfcc26d3b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery.json @@ -0,0 +1,25 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/gallery", + "isValid": true, + "attributes": { + "images": [ + { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "title", + "caption": "" + }, + { + "url": "http://google.com/hi.png", + "alt": "title", + "caption": "" + } + ], + "imageCrop": true, + "linkTo": "none" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery.parsed.json b/tests/phpunit/data/blocks/fixtures/core__gallery.parsed.json new file mode 100644 index 0000000000..3d80657c7f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/gallery", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery.serialized.html b/tests/phpunit/data/blocks/fixtures/core__gallery.serialized.html new file mode 100644 index 0000000000..5bf6ce819f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery__columns.html b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.html new file mode 100644 index 0000000000..cf1f1bb43f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.html @@ -0,0 +1,14 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery__columns.json b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.json new file mode 100644 index 0000000000..b3daaa05f6 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.json @@ -0,0 +1,26 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/gallery", + "isValid": true, + "attributes": { + "images": [ + { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "title", + "caption": "" + }, + { + "url": "http://google.com/hi.png", + "alt": "title", + "caption": "" + } + ], + "columns": 1, + "imageCrop": true, + "linkTo": "none" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery__columns.parsed.json b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.parsed.json new file mode 100644 index 0000000000..44faed907a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/gallery", + "attrs": { + "columns": 1 + }, + "innerBlocks": [], + "innerHTML": "\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__gallery__columns.serialized.html b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.serialized.html new file mode 100644 index 0000000000..183e484ec4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__gallery__columns.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.html b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.html new file mode 100644 index 0000000000..7755d1dcf4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.html @@ -0,0 +1,3 @@ + +

The Inserter Tool

+ diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.json b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.json new file mode 100644 index 0000000000..b72785dd6d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "The Inserter Tool", + "level": 2 + }, + "innerBlocks": [], + "originalContent": "

The Inserter Tool

" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.parsed.json b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.parsed.json new file mode 100644 index 0000000000..76d235d42c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/heading", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

The Inserter Tool

\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.serialized.html b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.serialized.html new file mode 100644 index 0000000000..55ce73502b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2-em.serialized.html @@ -0,0 +1,3 @@ + +

The Inserter Tool

+ diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2.html b/tests/phpunit/data/blocks/fixtures/core__heading__h2.html new file mode 100644 index 0000000000..a55b391a25 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2.html @@ -0,0 +1,3 @@ + +

A picture is worth a thousand words, or so the saying goes

+ diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2.json b/tests/phpunit/data/blocks/fixtures/core__heading__h2.json new file mode 100644 index 0000000000..f2073ff78b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/heading", + "isValid": true, + "attributes": { + "content": "A picture is worth a thousand words, or so the saying goes", + "level": 2 + }, + "innerBlocks": [], + "originalContent": "

A picture is worth a thousand words, or so the saying goes

" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2.parsed.json b/tests/phpunit/data/blocks/fixtures/core__heading__h2.parsed.json new file mode 100644 index 0000000000..700f5f941e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/heading", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

A picture is worth a thousand words, or so the saying goes

\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__heading__h2.serialized.html b/tests/phpunit/data/blocks/fixtures/core__heading__h2.serialized.html new file mode 100644 index 0000000000..1212bf83c3 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__heading__h2.serialized.html @@ -0,0 +1,3 @@ + +

A picture is worth a thousand words, or so the saying goes

+ diff --git a/tests/phpunit/data/blocks/fixtures/core__html.html b/tests/phpunit/data/blocks/fixtures/core__html.html new file mode 100644 index 0000000000..4824e6e373 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__html.html @@ -0,0 +1,4 @@ + +

Some HTML code

+This text will scroll from right to left + diff --git a/tests/phpunit/data/blocks/fixtures/core__html.json b/tests/phpunit/data/blocks/fixtures/core__html.json new file mode 100644 index 0000000000..cd7cf91f03 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__html.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/html", + "isValid": true, + "attributes": { + "content": "

Some HTML code

\nThis text will scroll from right to left" + }, + "innerBlocks": [], + "originalContent": "

Some HTML code

\nThis text will scroll from right to left" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__html.parsed.json b/tests/phpunit/data/blocks/fixtures/core__html.parsed.json new file mode 100644 index 0000000000..2bfdc65866 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__html.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/html", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

Some HTML code

\nThis text will scroll from right to left\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__html.serialized.html b/tests/phpunit/data/blocks/fixtures/core__html.serialized.html new file mode 100644 index 0000000000..8abffc385d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__html.serialized.html @@ -0,0 +1,4 @@ + +

Some HTML code

+This text will scroll from right to left + diff --git a/tests/phpunit/data/blocks/fixtures/core__image.html b/tests/phpunit/data/blocks/fixtures/core__image.html new file mode 100644 index 0000000000..eda663561a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image.json b/tests/phpunit/data/blocks/fixtures/core__image.json new file mode 100644 index 0000000000..4369150f0c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image.json @@ -0,0 +1,15 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/image", + "isValid": true, + "attributes": { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "", + "caption": "", + "linkDestination": "none" + }, + "innerBlocks": [], + "originalContent": "
\"\"
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image.parsed.json b/tests/phpunit/data/blocks/fixtures/core__image.parsed.json new file mode 100644 index 0000000000..fff414d9b0 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/image", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
\"\"
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image.serialized.html b/tests/phpunit/data/blocks/fixtures/core__image.serialized.html new file mode 100644 index 0000000000..5dfb0bac3e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image.serialized.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.html b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.html new file mode 100644 index 0000000000..908250d8ca --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.json b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.json new file mode 100644 index 0000000000..5d16958904 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/image", + "isValid": true, + "attributes": { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "", + "caption": "", + "href": "http://localhost:8888/?attachment_id=7", + "linkDestination": "attachment" + }, + "innerBlocks": [], + "originalContent": "
\"\"
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.parsed.json b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.parsed.json new file mode 100644 index 0000000000..e5da07242d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/image", + "attrs": { + "linkDestination": "attachment" + }, + "innerBlocks": [], + "innerHTML": "\n
\"\"
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.serialized.html b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.serialized.html new file mode 100644 index 0000000000..f5ebb9af41 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__attachment-link.serialized.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__center-caption.html b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.html new file mode 100644 index 0000000000..bfe40d190f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.html @@ -0,0 +1,3 @@ + +
Give it a try. Press the "really wide" button on the image toolbar.
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__center-caption.json b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.json new file mode 100644 index 0000000000..f569bda22c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/image", + "isValid": true, + "attributes": { + "url": "https://cldup.com/YLYhpou2oq.jpg", + "alt": "", + "caption": "Give it a try. Press the \"really wide\" button on the image toolbar.", + "align": "center", + "linkDestination": "none" + }, + "innerBlocks": [], + "originalContent": "
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__center-caption.parsed.json b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.parsed.json new file mode 100644 index 0000000000..290057c287 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/image", + "attrs": { + "align": "center" + }, + "innerBlocks": [], + "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__center-caption.serialized.html b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.serialized.html new file mode 100644 index 0000000000..3410b04fdf --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__center-caption.serialized.html @@ -0,0 +1,3 @@ + +
Give it a try. Press the "really wide" button on the image toolbar.
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__custom-link.html b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.html new file mode 100644 index 0000000000..353dc5376b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__custom-link.json b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.json new file mode 100644 index 0000000000..735e552282 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/image", + "isValid": true, + "attributes": { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "", + "caption": "", + "href": "https://wordpress.org/", + "linkDestination": "custom" + }, + "innerBlocks": [], + "originalContent": "
\"\"
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__custom-link.parsed.json b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.parsed.json new file mode 100644 index 0000000000..d814737aae --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/image", + "attrs": { + "linkDestination": "custom" + }, + "innerBlocks": [], + "innerHTML": "\n
\"\"
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__custom-link.serialized.html b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.serialized.html new file mode 100644 index 0000000000..47357bea6b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__custom-link.serialized.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__media-link.html b/tests/phpunit/data/blocks/fixtures/core__image__media-link.html new file mode 100644 index 0000000000..90b3d22711 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__media-link.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__image__media-link.json b/tests/phpunit/data/blocks/fixtures/core__image__media-link.json new file mode 100644 index 0000000000..690fa778b6 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__media-link.json @@ -0,0 +1,16 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/image", + "isValid": true, + "attributes": { + "url": "https://cldup.com/uuUqE_dXzy.jpg", + "alt": "", + "caption": "", + "href": "https://cldup.com/uuUqE_dXzy.jpg", + "linkDestination": "media" + }, + "innerBlocks": [], + "originalContent": "
\"\"
" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__media-link.parsed.json b/tests/phpunit/data/blocks/fixtures/core__image__media-link.parsed.json new file mode 100644 index 0000000000..345c5d4e25 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__media-link.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/image", + "attrs": { + "linkDestination": "media" + }, + "innerBlocks": [], + "innerHTML": "\n
\"\"
\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__image__media-link.serialized.html b/tests/phpunit/data/blocks/fixtures/core__image__media-link.serialized.html new file mode 100644 index 0000000000..721abac903 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__image__media-link.serialized.html @@ -0,0 +1,3 @@ + +
+ diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.html b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.html new file mode 100644 index 0000000000..1eaeb57026 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.json b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.json new file mode 100644 index 0000000000..91dc39fca8 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/freeform", + "isValid": true, + "attributes": { + "content": "

" + }, + "innerBlocks": [], + "originalContent": "

" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.parsed.json b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.parsed.json new file mode 100644 index 0000000000..c17c81b398 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.parsed.json @@ -0,0 +1,8 @@ +[ + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.serialized.html b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.serialized.html new file mode 100644 index 0000000000..4b0ff53da7 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-Capitals.serialized.html @@ -0,0 +1 @@ +

diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-special.html b/tests/phpunit/data/blocks/fixtures/core__invalid-special.html new file mode 100644 index 0000000000..548aef63c7 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-special.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-special.json b/tests/phpunit/data/blocks/fixtures/core__invalid-special.json new file mode 100644 index 0000000000..cd026a2a3c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-special.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/freeform", + "isValid": true, + "attributes": { + "content": "

" + }, + "innerBlocks": [], + "originalContent": "

" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-special.parsed.json b/tests/phpunit/data/blocks/fixtures/core__invalid-special.parsed.json new file mode 100644 index 0000000000..3198b43be5 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-special.parsed.json @@ -0,0 +1,8 @@ +[ + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__invalid-special.serialized.html b/tests/phpunit/data/blocks/fixtures/core__invalid-special.serialized.html new file mode 100644 index 0000000000..de4f2acc41 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__invalid-special.serialized.html @@ -0,0 +1 @@ +

diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-comments.html b/tests/phpunit/data/blocks/fixtures/core__latest-comments.html new file mode 100644 index 0000000000..cc4a2523b9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-comments.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-comments.json b/tests/phpunit/data/blocks/fixtures/core__latest-comments.json new file mode 100644 index 0000000000..a455877276 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-comments.json @@ -0,0 +1,15 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/latest-comments", + "isValid": true, + "attributes": { + "commentsToShow": 5, + "displayAvatar": true, + "displayDate": true, + "displayExcerpt": true + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-comments.parsed.json b/tests/phpunit/data/blocks/fixtures/core__latest-comments.parsed.json new file mode 100644 index 0000000000..7e8bb541ad --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-comments.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/latest-comments", + "attrs": { + "displayAvatar": true, + "displayExcerpt": true, + "displayTimestamp": true + }, + "innerBlocks": [], + "innerHTML": "" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-comments.serialized.html b/tests/phpunit/data/blocks/fixtures/core__latest-comments.serialized.html new file mode 100644 index 0000000000..a50d5664a6 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-comments.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts.html b/tests/phpunit/data/blocks/fixtures/core__latest-posts.html new file mode 100644 index 0000000000..99d215f58a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts.json b/tests/phpunit/data/blocks/fixtures/core__latest-posts.json new file mode 100644 index 0000000000..f31c903f58 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts.json @@ -0,0 +1,17 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/latest-posts", + "isValid": true, + "attributes": { + "postsToShow": 5, + "displayPostDate": false, + "postLayout": "list", + "columns": 3, + "order": "desc", + "orderBy": "date" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts.parsed.json b/tests/phpunit/data/blocks/fixtures/core__latest-posts.parsed.json new file mode 100644 index 0000000000..f1c800291d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/latest-posts", + "attrs": { + "postsToShow": 5, + "displayPostDate": false + }, + "innerBlocks": [], + "innerHTML": "" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts.serialized.html b/tests/phpunit/data/blocks/fixtures/core__latest-posts.serialized.html new file mode 100644 index 0000000000..2c5b3f264c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.html b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.html new file mode 100644 index 0000000000..d3128a6682 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.json b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.json new file mode 100644 index 0000000000..024e1a7f37 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.json @@ -0,0 +1,17 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/latest-posts", + "isValid": true, + "attributes": { + "postsToShow": 5, + "displayPostDate": true, + "postLayout": "list", + "columns": 3, + "order": "desc", + "orderBy": "date" + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.parsed.json b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.parsed.json new file mode 100644 index 0000000000..a92b392679 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/latest-posts", + "attrs": { + "postsToShow": 5, + "displayPostDate": true + }, + "innerBlocks": [], + "innerHTML": "" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.serialized.html b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.serialized.html new file mode 100644 index 0000000000..0d80d351d6 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__latest-posts__displayPostDate.serialized.html @@ -0,0 +1 @@ + diff --git a/tests/phpunit/data/blocks/fixtures/core__list__ul.html b/tests/phpunit/data/blocks/fixtures/core__list__ul.html new file mode 100644 index 0000000000..aef6bf669f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__list__ul.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__list__ul.json b/tests/phpunit/data/blocks/fixtures/core__list__ul.json new file mode 100644 index 0000000000..17baec7cef --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__list__ul.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/list", + "isValid": true, + "attributes": { + "ordered": false, + "values": "
  • Text & Headings
  • Images & Videos
  • Galleries
  • Embeds, like YouTube, Tweets, or other WordPress posts.
  • Layout blocks, like Buttons, Hero Images, Separators, etc.
  • And Lists like this one of course :)
  • " + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__list__ul.parsed.json b/tests/phpunit/data/blocks/fixtures/core__list__ul.parsed.json new file mode 100644 index 0000000000..c42181ba55 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__list__ul.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/list", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__list__ul.serialized.html b/tests/phpunit/data/blocks/fixtures/core__list__ul.serialized.html new file mode 100644 index 0000000000..6b83b73a47 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__list__ul.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__missing.html b/tests/phpunit/data/blocks/fixtures/core__missing.html new file mode 100644 index 0000000000..a29cbdea3f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__missing.html @@ -0,0 +1,6 @@ + +

    Testing missing block with some

    +
    + HTML content +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__missing.json b/tests/phpunit/data/blocks/fixtures/core__missing.json new file mode 100644 index 0000000000..4e90cf7132 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__missing.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/missing", + "isValid": true, + "attributes": { + "originalContent": "\n

    Testing missing block with some

    \n
    \n\tHTML content\n
    \n", + "originalName": "unregistered/example", + "originalUndelimitedContent": "

    Testing missing block with some

    \n
    \n\tHTML content\n
    " + }, + "innerBlocks": [], + "originalContent": "\n

    Testing missing block with some

    \n
    \n\tHTML content\n
    \n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__missing.parsed.json b/tests/phpunit/data/blocks/fixtures/core__missing.parsed.json new file mode 100644 index 0000000000..3466b8cf2a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__missing.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "unregistered/example", + "attrs": { + "attr1": "One", + "attr2": "Two" + }, + "innerBlocks": [], + "innerHTML": "\n

    Testing missing block with some

    \n
    \n\tHTML content\n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__missing.serialized.html b/tests/phpunit/data/blocks/fixtures/core__missing.serialized.html new file mode 100644 index 0000000000..a29cbdea3f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__missing.serialized.html @@ -0,0 +1,6 @@ + +

    Testing missing block with some

    +
    + HTML content +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__more.html b/tests/phpunit/data/blocks/fixtures/core__more.html new file mode 100644 index 0000000000..b3b4f9e5e4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__more.json b/tests/phpunit/data/blocks/fixtures/core__more.json new file mode 100644 index 0000000000..886638ab06 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/more", + "isValid": true, + "attributes": { + "noTeaser": false + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__more.parsed.json b/tests/phpunit/data/blocks/fixtures/core__more.parsed.json new file mode 100644 index 0000000000..176e7fe7f7 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/more", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__more.serialized.html b/tests/phpunit/data/blocks/fixtures/core__more.serialized.html new file mode 100644 index 0000000000..3b02c97e91 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.html b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.html new file mode 100644 index 0000000000..1dcca90966 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.html @@ -0,0 +1,4 @@ + + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.json b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.json new file mode 100644 index 0000000000..7f7811e0d1 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/more", + "isValid": true, + "attributes": { + "customText": "Continue Reading", + "noTeaser": true + }, + "innerBlocks": [], + "originalContent": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.parsed.json b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.parsed.json new file mode 100644 index 0000000000..a533e3c09c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.parsed.json @@ -0,0 +1,17 @@ +[ + { + "blockName": "core/more", + "attrs": { + "customText": "Continue Reading", + "noTeaser": true + }, + "innerBlocks": [], + "innerHTML": "\n\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.serialized.html b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.serialized.html new file mode 100644 index 0000000000..6cc18dcfba --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__more__custom-text-teaser.serialized.html @@ -0,0 +1,4 @@ + + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__nextpage.html b/tests/phpunit/data/blocks/fixtures/core__nextpage.html new file mode 100644 index 0000000000..9bf78b8cbf --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__nextpage.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__nextpage.json b/tests/phpunit/data/blocks/fixtures/core__nextpage.json new file mode 100644 index 0000000000..1a2c5478ae --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__nextpage.json @@ -0,0 +1,10 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/nextpage", + "isValid": true, + "attributes": {}, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__nextpage.parsed.json b/tests/phpunit/data/blocks/fixtures/core__nextpage.parsed.json new file mode 100644 index 0000000000..e4dd2534c8 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__nextpage.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/nextpage", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__nextpage.serialized.html b/tests/phpunit/data/blocks/fixtures/core__nextpage.serialized.html new file mode 100644 index 0000000000..beef64ebd5 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__nextpage.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.html b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.html new file mode 100644 index 0000000000..d41481a57f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.html @@ -0,0 +1,3 @@ + +

    ... like this one, which is separate from the above and right aligned.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.json b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.json new file mode 100644 index 0000000000..079d9a704f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "... like this one, which is separate from the above and right aligned.", + "align": "right", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

    ... like this one, which is separate from the above and right aligned.

    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.parsed.json b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.parsed.json new file mode 100644 index 0000000000..060d40a38d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/paragraph", + "attrs": { + "align": "right" + }, + "innerBlocks": [], + "innerHTML": "\n

    ... like this one, which is separate from the above and right aligned.

    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.serialized.html b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.serialized.html new file mode 100644 index 0000000000..3e18265b5c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__align-right.serialized.html @@ -0,0 +1,3 @@ + +

    ... like this one, which is separate from the above and right aligned.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.html b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.html new file mode 100644 index 0000000000..96ec545b64 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.html @@ -0,0 +1,3 @@ + +Unwrapped is still valid. + diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.json b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.json new file mode 100644 index 0000000000..ce0f468e35 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Unwrapped is still valid.", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "Unwrapped is still valid." + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.parsed.json b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.parsed.json new file mode 100644 index 0000000000..ac11af1b3a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\nUnwrapped is still valid.\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.serialized.html b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.serialized.html new file mode 100644 index 0000000000..ddc0a9d9a1 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__paragraph__deprecated.serialized.html @@ -0,0 +1,3 @@ + +

    Unwrapped is still valid.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__preformatted.html b/tests/phpunit/data/blocks/fixtures/core__preformatted.html new file mode 100644 index 0000000000..1a890a7a5d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__preformatted.html @@ -0,0 +1,3 @@ + +
    Some preformatted text...
    And more!
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__preformatted.json b/tests/phpunit/data/blocks/fixtures/core__preformatted.json new file mode 100644 index 0000000000..290c7e9849 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__preformatted.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/preformatted", + "isValid": true, + "attributes": { + "content": "Some preformatted text...
    And more!" + }, + "innerBlocks": [], + "originalContent": "
    Some preformatted text...
    And more!
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__preformatted.parsed.json b/tests/phpunit/data/blocks/fixtures/core__preformatted.parsed.json new file mode 100644 index 0000000000..247fdda2e3 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__preformatted.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/preformatted", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    Some preformatted text...
    And more!
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__preformatted.serialized.html b/tests/phpunit/data/blocks/fixtures/core__preformatted.serialized.html new file mode 100644 index 0000000000..8c7cf539e4 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__preformatted.serialized.html @@ -0,0 +1,3 @@ + +
    Some preformatted text...
    And more!
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote.html b/tests/phpunit/data/blocks/fixtures/core__pullquote.html new file mode 100644 index 0000000000..87bd8b74f9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote.html @@ -0,0 +1,7 @@ + +
    +
    +

    Testing pullquote block...

    ...with a caption +
    +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote.json b/tests/phpunit/data/blocks/fixtures/core__pullquote.json new file mode 100644 index 0000000000..5cf126489b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/pullquote", + "isValid": true, + "attributes": { + "value": "

    Testing pullquote block...

    ", + "citation": "...with a caption" + }, + "innerBlocks": [], + "originalContent": "
    \n
    \n

    Testing pullquote block...

    ...with a caption\n
    \n
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote.parsed.json b/tests/phpunit/data/blocks/fixtures/core__pullquote.parsed.json new file mode 100644 index 0000000000..0e39eea4ec --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/pullquote", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    \n
    \n

    Testing pullquote block...

    ...with a caption\n
    \n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote.serialized.html b/tests/phpunit/data/blocks/fixtures/core__pullquote.serialized.html new file mode 100644 index 0000000000..6ef3209575 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote.serialized.html @@ -0,0 +1,3 @@ + +

    Testing pullquote block...

    ...with a caption
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.html b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.html new file mode 100644 index 0000000000..eace115333 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.html @@ -0,0 +1,9 @@ + +
    +
    +

    Paragraph one

    +

    Paragraph two

    + by whomever +
    +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.json b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.json new file mode 100644 index 0000000000..81c058e5ab --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/pullquote", + "isValid": true, + "attributes": { + "value": "

    Paragraph one

    Paragraph two

    ", + "citation": "by whomever" + }, + "innerBlocks": [], + "originalContent": "
    \n
    \n

    Paragraph one

    \n

    Paragraph two

    \n by whomever\n\t
    \n
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.parsed.json b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.parsed.json new file mode 100644 index 0000000000..3b303a0d8d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/pullquote", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    \n
    \n

    Paragraph one

    \n

    Paragraph two

    \n by whomever\n\t
    \n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.serialized.html b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.serialized.html new file mode 100644 index 0000000000..333b051f19 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__pullquote__multi-paragraph.serialized.html @@ -0,0 +1,3 @@ + +

    Paragraph one

    Paragraph two

    by whomever
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-1.html b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.html new file mode 100644 index 0000000000..4bfd0ef80e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.html @@ -0,0 +1,3 @@ + +

    The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.

    Matt Mullenweg, 2017
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-1.json b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.json new file mode 100644 index 0000000000..cd8d15bcc9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/quote", + "isValid": true, + "attributes": { + "value": "

    The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.

    ", + "citation": "Matt Mullenweg, 2017" + }, + "innerBlocks": [], + "originalContent": "

    The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.

    Matt Mullenweg, 2017
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-1.parsed.json b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.parsed.json new file mode 100644 index 0000000000..12f480ef31 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/quote", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

    The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.

    Matt Mullenweg, 2017
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-1.serialized.html b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.serialized.html new file mode 100644 index 0000000000..4268c41398 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-1.serialized.html @@ -0,0 +1,3 @@ + +

    The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.

    Matt Mullenweg, 2017
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-2.html b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.html new file mode 100644 index 0000000000..d4ecdca350 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.html @@ -0,0 +1,3 @@ + +

    There is no greater agony than bearing an untold story inside you.

    Maya Angelou
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-2.json b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.json new file mode 100644 index 0000000000..300770c72c --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.json @@ -0,0 +1,14 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/quote", + "isValid": true, + "attributes": { + "value": "

    There is no greater agony than bearing an untold story inside you.

    ", + "citation": "Maya Angelou", + "className": "is-style-large" + }, + "innerBlocks": [], + "originalContent": "

    There is no greater agony than bearing an untold story inside you.

    Maya Angelou
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-2.parsed.json b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.parsed.json new file mode 100644 index 0000000000..87a9377e2e --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/quote", + "attrs": { + "className": "is-style-large" + }, + "innerBlocks": [], + "innerHTML": "\n

    There is no greater agony than bearing an untold story inside you.

    Maya Angelou
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__quote__style-2.serialized.html b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.serialized.html new file mode 100644 index 0000000000..b257de2408 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__quote__style-2.serialized.html @@ -0,0 +1,3 @@ + +

    There is no greater agony than bearing an untold story inside you.

    Maya Angelou
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__separator.html b/tests/phpunit/data/blocks/fixtures/core__separator.html new file mode 100644 index 0000000000..d835a48314 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__separator.html @@ -0,0 +1,3 @@ + +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__separator.json b/tests/phpunit/data/blocks/fixtures/core__separator.json new file mode 100644 index 0000000000..12a687c00a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__separator.json @@ -0,0 +1,10 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/separator", + "isValid": true, + "attributes": {}, + "innerBlocks": [], + "originalContent": "
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__separator.parsed.json b/tests/phpunit/data/blocks/fixtures/core__separator.parsed.json new file mode 100644 index 0000000000..d01eb1eed1 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__separator.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/separator", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__separator.serialized.html b/tests/phpunit/data/blocks/fixtures/core__separator.serialized.html new file mode 100644 index 0000000000..cb5aeea740 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__separator.serialized.html @@ -0,0 +1,3 @@ + +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__shortcode.html b/tests/phpunit/data/blocks/fixtures/core__shortcode.html new file mode 100644 index 0000000000..ed4bd8928d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__shortcode.html @@ -0,0 +1,3 @@ + +[gallery ids="238,338"] + diff --git a/tests/phpunit/data/blocks/fixtures/core__shortcode.json b/tests/phpunit/data/blocks/fixtures/core__shortcode.json new file mode 100644 index 0000000000..0f1d3e559d --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__shortcode.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/shortcode", + "isValid": true, + "attributes": { + "text": "[gallery ids=\"238,338\"]" + }, + "innerBlocks": [], + "originalContent": "[gallery ids=\"238,338\"]" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__shortcode.parsed.json b/tests/phpunit/data/blocks/fixtures/core__shortcode.parsed.json new file mode 100644 index 0000000000..70d24dc276 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__shortcode.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/shortcode", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n[gallery ids=\"238,338\"]\n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__shortcode.serialized.html b/tests/phpunit/data/blocks/fixtures/core__shortcode.serialized.html new file mode 100644 index 0000000000..293b698359 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__shortcode.serialized.html @@ -0,0 +1,3 @@ + +[gallery ids="238,338"] + diff --git a/tests/phpunit/data/blocks/fixtures/core__spacer.html b/tests/phpunit/data/blocks/fixtures/core__spacer.html new file mode 100644 index 0000000000..e7c1e25619 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__spacer.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__spacer.json b/tests/phpunit/data/blocks/fixtures/core__spacer.json new file mode 100644 index 0000000000..a157520b75 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__spacer.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/spacer", + "isValid": true, + "attributes": { + "height": 100 + }, + "innerBlocks": [], + "originalContent": "
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__spacer.parsed.json b/tests/phpunit/data/blocks/fixtures/core__spacer.parsed.json new file mode 100644 index 0000000000..8b8baa2a7f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__spacer.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/spacer", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__spacer.serialized.html b/tests/phpunit/data/blocks/fixtures/core__spacer.serialized.html new file mode 100644 index 0000000000..e7c1e25619 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__spacer.serialized.html @@ -0,0 +1,3 @@ + + + diff --git a/tests/phpunit/data/blocks/fixtures/core__subhead.html b/tests/phpunit/data/blocks/fixtures/core__subhead.html new file mode 100644 index 0000000000..61cf931896 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__subhead.html @@ -0,0 +1,3 @@ + +

    This is a subhead.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__subhead.json b/tests/phpunit/data/blocks/fixtures/core__subhead.json new file mode 100644 index 0000000000..a0c58740e2 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__subhead.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/subhead", + "isValid": true, + "attributes": { + "content": "This is a subhead." + }, + "innerBlocks": [], + "originalContent": "

    This is a subhead.

    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__subhead.parsed.json b/tests/phpunit/data/blocks/fixtures/core__subhead.parsed.json new file mode 100644 index 0000000000..06ca46da1b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__subhead.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/subhead", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

    This is a subhead.

    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__subhead.serialized.html b/tests/phpunit/data/blocks/fixtures/core__subhead.serialized.html new file mode 100644 index 0000000000..2346819208 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__subhead.serialized.html @@ -0,0 +1,3 @@ + +

    This is a subhead.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__table.html b/tests/phpunit/data/blocks/fixtures/core__table.html new file mode 100644 index 0000000000..b9b41659e8 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__table.html @@ -0,0 +1,3 @@ + +
    VersionMusicianDate
    .70No musician chosen.May 27, 2003
    1.0Miles DavisJanuary 3, 2004
    Lots of versions skipped, see the full list
    4.4Clifford BrownDecember 8, 2015
    4.5Coleman HawkinsApril 12, 2016
    4.6Pepper AdamsAugust 16, 2016
    4.7Sarah VaughanDecember 6, 2016
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__table.json b/tests/phpunit/data/blocks/fixtures/core__table.json new file mode 100644 index 0000000000..7d71d09c53 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__table.json @@ -0,0 +1,145 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/table", + "isValid": true, + "attributes": { + "hasFixedLayout": false, + "head": [ + { + "cells": [ + { + "content": "Version", + "tag": "th" + }, + { + "content": "Musician", + "tag": "th" + }, + { + "content": "Date", + "tag": "th" + } + ] + } + ], + "body": [ + { + "cells": [ + { + "content": ".70", + "tag": "td" + }, + { + "content": "No musician chosen.", + "tag": "td" + }, + { + "content": "May 27, 2003", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "1.0", + "tag": "td" + }, + { + "content": "Miles Davis", + "tag": "td" + }, + { + "content": "January 3, 2004", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "Lots of versions skipped, see the full list", + "tag": "td" + }, + { + "content": "…", + "tag": "td" + }, + { + "content": "…", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.4", + "tag": "td" + }, + { + "content": "Clifford Brown", + "tag": "td" + }, + { + "content": "December 8, 2015", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.5", + "tag": "td" + }, + { + "content": "Coleman Hawkins", + "tag": "td" + }, + { + "content": "April 12, 2016", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.6", + "tag": "td" + }, + { + "content": "Pepper Adams", + "tag": "td" + }, + { + "content": "August 16, 2016", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.7", + "tag": "td" + }, + { + "content": "Sarah Vaughan", + "tag": "td" + }, + { + "content": "December 6, 2016", + "tag": "td" + } + ] + } + ], + "foot": [] + }, + "innerBlocks": [], + "originalContent": "
    VersionMusicianDate
    .70No musician chosen.May 27, 2003
    1.0Miles DavisJanuary 3, 2004
    Lots of versions skipped, see the full list
    4.4Clifford BrownDecember 8, 2015
    4.5Coleman HawkinsApril 12, 2016
    4.6Pepper AdamsAugust 16, 2016
    4.7Sarah VaughanDecember 6, 2016
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__table.parsed.json b/tests/phpunit/data/blocks/fixtures/core__table.parsed.json new file mode 100644 index 0000000000..8c24b96113 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__table.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/table", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    VersionMusicianDate
    .70No musician chosen.May 27, 2003
    1.0Miles DavisJanuary 3, 2004
    Lots of versions skipped, see the full list
    4.4Clifford BrownDecember 8, 2015
    4.5Coleman HawkinsApril 12, 2016
    4.6Pepper AdamsAugust 16, 2016
    4.7Sarah VaughanDecember 6, 2016
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__table.serialized.html b/tests/phpunit/data/blocks/fixtures/core__table.serialized.html new file mode 100644 index 0000000000..a791eb149f --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__table.serialized.html @@ -0,0 +1,3 @@ + +
    VersionMusicianDate
    .70No musician chosen.May 27, 2003
    1.0Miles DavisJanuary 3, 2004
    Lots of versions skipped, see the full list
    4.4Clifford BrownDecember 8, 2015
    4.5Coleman HawkinsApril 12, 2016
    4.6Pepper AdamsAugust 16, 2016
    4.7Sarah VaughanDecember 6, 2016
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__text-columns.html b/tests/phpunit/data/blocks/fixtures/core__text-columns.html new file mode 100644 index 0000000000..a273839c39 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text-columns.html @@ -0,0 +1,10 @@ + +
    +
    +

    One

    +
    +
    +

    Two

    +
    +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__text-columns.json b/tests/phpunit/data/blocks/fixtures/core__text-columns.json new file mode 100644 index 0000000000..f610db9e55 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text-columns.json @@ -0,0 +1,21 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/text-columns", + "isValid": true, + "attributes": { + "content": [ + { + "children": "One" + }, + { + "children": "Two" + } + ], + "columns": 2, + "width": "center" + }, + "innerBlocks": [], + "originalContent": "
    \n
    \n

    One

    \n
    \n
    \n

    Two

    \n
    \n
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__text-columns.parsed.json b/tests/phpunit/data/blocks/fixtures/core__text-columns.parsed.json new file mode 100644 index 0000000000..293c930ac5 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text-columns.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/text-columns", + "attrs": { + "width": "center" + }, + "innerBlocks": [], + "innerHTML": "\n
    \n
    \n

    One

    \n
    \n
    \n

    Two

    \n
    \n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__text-columns.serialized.html b/tests/phpunit/data/blocks/fixtures/core__text-columns.serialized.html new file mode 100644 index 0000000000..8ae01efcb9 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text-columns.serialized.html @@ -0,0 +1,3 @@ + +

    One

    Two

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.html b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.html new file mode 100644 index 0000000000..a1d47a56e0 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.html @@ -0,0 +1,3 @@ + +

    This is an old-style text block. Changed to paragraph in #2135.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.json b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.json new file mode 100644 index 0000000000..2f85e75d9a --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.json @@ -0,0 +1,13 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "This is an old-style text block. Changed to paragraph in #2135.", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

    This is an old-style text block. Changed to paragraph in #2135.

    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.parsed.json b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.parsed.json new file mode 100644 index 0000000000..958d2a2921 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/text", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n

    This is an old-style text block. Changed to paragraph in #2135.

    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.serialized.html b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.serialized.html new file mode 100644 index 0000000000..61fd699dac --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__text__converts-to-paragraph.serialized.html @@ -0,0 +1,3 @@ + +

    This is an old-style text block. Changed to paragraph in #2135.

    + diff --git a/tests/phpunit/data/blocks/fixtures/core__verse.html b/tests/phpunit/data/blocks/fixtures/core__verse.html new file mode 100644 index 0000000000..0e6904a898 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__verse.html @@ -0,0 +1,3 @@ + +
    A verse
    And more!
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__verse.json b/tests/phpunit/data/blocks/fixtures/core__verse.json new file mode 100644 index 0000000000..5c6e3d83e6 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__verse.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/verse", + "isValid": true, + "attributes": { + "content": "A verse
    And more!" + }, + "innerBlocks": [], + "originalContent": "
    A verse
    And more!
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__verse.parsed.json b/tests/phpunit/data/blocks/fixtures/core__verse.parsed.json new file mode 100644 index 0000000000..4f244cb551 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__verse.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/verse", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    A verse
    And more!
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__verse.serialized.html b/tests/phpunit/data/blocks/fixtures/core__verse.serialized.html new file mode 100644 index 0000000000..a601b25991 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__verse.serialized.html @@ -0,0 +1,3 @@ + +
    A verse
    And more!
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__video.html b/tests/phpunit/data/blocks/fixtures/core__video.html new file mode 100644 index 0000000000..dd720ecda8 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__video.html @@ -0,0 +1,3 @@ + +
    + diff --git a/tests/phpunit/data/blocks/fixtures/core__video.json b/tests/phpunit/data/blocks/fixtures/core__video.json new file mode 100644 index 0000000000..e91fd20c5b --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__video.json @@ -0,0 +1,18 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/video", + "isValid": true, + "attributes": { + "autoplay": false, + "caption": "", + "controls": true, + "loop": false, + "muted": false, + "preload": "metadata", + "src": "https://awesome-fake.video/file.mp4" + }, + "innerBlocks": [], + "originalContent": "
    " + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__video.parsed.json b/tests/phpunit/data/blocks/fixtures/core__video.parsed.json new file mode 100644 index 0000000000..7b448d6f38 --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__video.parsed.json @@ -0,0 +1,14 @@ +[ + { + "blockName": "core/video", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
    \n" + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n" + } +] diff --git a/tests/phpunit/data/blocks/fixtures/core__video.serialized.html b/tests/phpunit/data/blocks/fixtures/core__video.serialized.html new file mode 100644 index 0000000000..48dca62aec --- /dev/null +++ b/tests/phpunit/data/blocks/fixtures/core__video.serialized.html @@ -0,0 +1,3 @@ + +
    + diff --git a/tests/phpunit/tests/blocks/block-parser.php b/tests/phpunit/tests/blocks/block-parser.php new file mode 100644 index 0000000000..3818cd9816 --- /dev/null +++ b/tests/phpunit/tests/blocks/block-parser.php @@ -0,0 +1,120 @@ +parse( $html ) ), true ); + + $this->assertEquals( + $expected_parsed, + $result, + "File '$parsed_json_filename' does not match expected value" + ); + } + + /** + * Helper function to remove relative paths and extension from a filename, leaving just the fixture name. + * + * @since 5.0.0 + * + * @param string $filename The filename to clean. + * @return string The cleaned fixture name. + */ + protected function clean_fixture_filename( $filename ) { + $filename = basename( $filename ); + $filename = preg_replace( '/\..+$/', '', $filename ); + return $filename; + } + + /** + * Helper function to return the filenames needed to test the parser output. + * + * @since 5.0.0 + * + * @param string $filename The cleaned fixture name. + * @return array The input and expected output filenames for that fixture. + */ + protected function pass_parser_fixture_filenames( $filename ) { + return array( + "$filename.html", + "$filename.parsed.json", + ); + } + + /** + * Helper function to remove '\r' characters from a string. + * + * @since 5.0.0 + * + * @param string $input The string to remove '\r' from. + * @return string The input string, with '\r' characters removed. + */ + protected function strip_r( $input ) { + return str_replace( "\r", '', $input ); + } + +} diff --git a/tools/webpack/packages.js b/tools/webpack/packages.js index 3040d854d7..9376d37e1b 100644 --- a/tools/webpack/packages.js +++ b/tools/webpack/packages.js @@ -116,6 +116,10 @@ module.exports = function( env = { environment: 'production', watch: false } ) { 'wp-polyfill-node-contains.min.js': 'polyfill-library/polyfills/Node/prototype/contains/polyfill.js', }; + const phpFiles = { + 'block-serialization-default-parser/parser.php': 'wp-includes/class-wp-block-parser.php', + }; + const externals = { react: 'React', 'react-dom': 'ReactDOM', @@ -164,6 +168,11 @@ module.exports = function( env = { environment: 'production', watch: false } ) { } } ) ); + const phpCopies = Object.keys( phpFiles ).map( ( filename ) => ( { + from: join( baseDir, `node_modules/@wordpress/${ filename }` ), + to: join( baseDir, `src/${ phpFiles[ filename ] }` ), + } ) ); + const config = { mode, @@ -232,6 +241,7 @@ module.exports = function( env = { environment: 'production', watch: false } ) { [ ...vendorCopies, ...cssCopies, + ...phpCopies, ], ), ],