Make WordPress Core

Changeset 56607


Ignore:
Timestamp:
09/18/2023 10:33:24 AM (3 years ago)
Author:
gziolo
Message:

Tests: Add additional tests covering Block Hooks registration

Props ockham.
See #59346.
Follow-up [56587].

Location:
trunk/tests/phpunit
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/data/blocks/notice/block.json

    r56587 r56607  
    3232        },
    3333        "blockHooks": {
    34                 "core/post-content": "before"
     34                "tests/before": "before",
     35                "tests/after": "after",
     36                "tests/first-child": "firstChild",
     37                "tests/last-child": "lastChild"
    3538        },
    3639        "supports": {
  • trunk/tests/phpunit/tests/blocks/register.php

    r56587 r56607  
    646646                );
    647647                // @ticket 59346
    648                 $this->assertSame(
    649                         array( 'core/post-content' => 'before' ),
     648                $this->assertSameSets(
     649                        array(
     650                                'tests/before'      => 'before',
     651                                'tests/after'       => 'after',
     652                                'tests/first-child' => 'first_child',
     653                                'tests/last-child'  => 'last_child',
     654                        ),
    650655                        $result->block_hooks,
    651656                        'Block type should contain block hooks from metadata.'
     
    10701075                $this->assertTrue( $actual );
    10711076        }
     1077
     1078        /**
     1079         * @ticket 59346
     1080         *
     1081         * @covers ::register_block_type
     1082         *
     1083         * @expectedIncorrectUsage register_block_type_from_metadata
     1084         */
     1085        public function test_register_block_hooks_targeting_itself() {
     1086                $block_type = register_block_type(
     1087                        DIR_TESTDATA . '/blocks/hooked-block-error'
     1088                );
     1089
     1090                $this->assertSame(
     1091                        array( 'tests/other-block' => 'after' ),
     1092                        $block_type->block_hooks
     1093                );
     1094        }
    10721095}
Note: See TracChangeset for help on using the changeset viewer.