Make WordPress Core


Ignore:
Timestamp:
02/02/2024 08:22:11 PM (2 years ago)
Author:
gziolo
Message:

Editor: Refactor the way block bindings sources are handled

It fixes the coding style issues reported. It goes further and improves the code quality it other places where the logic for block bindings was added.

Follow-up for [57514].
Props: gziolo, mukesh27, youknowriad, santosguillamot.
See #60282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-bindings/register.php

    r57514 r57526  
    1818
    1919    /**
    20      * Set up before each test.
    21      *
    22      * @since 6.5.0
    23      */
    24     public function set_up() {
    25         foreach ( get_all_registered_block_bindings_sources() as $source_name => $source_properties ) {
    26             unregister_block_bindings_source( $source_name );
    27         }
    28 
    29         parent::set_up();
    30     }
    31 
    32     /**
    3320     * Tear down after each test.
    3421     *
     
    3724    public function tear_down() {
    3825        foreach ( get_all_registered_block_bindings_sources() as $source_name => $source_properties ) {
    39             unregister_block_bindings_source( $source_name );
     26            if ( str_starts_with( $source_name, 'test/' ) ) {
     27                unregister_block_bindings_source( $source_name );
     28            }
    4029        }
    4130
     
    5039     * @covers ::register_block_bindings_source
    5140     * @covers ::get_all_registered_block_bindings_sources
     41     * @covers ::get_block_bindings_source
    5242     */
    5343    public function test_get_all_registered() {
     
    6555
    6656        $expected = array(
    67             $source_one_name   => array_merge( array( 'name' => $source_one_name ), $source_one_properties ),
    68             $source_two_name   => array_merge( array( 'name' => $source_two_name ), $source_two_properties ),
    69             $source_three_name => array_merge( array( 'name' => $source_three_name ), $source_three_properties ),
     57            $source_one_name         => array_merge( array( 'name' => $source_one_name ), $source_one_properties ),
     58            $source_two_name         => array_merge( array( 'name' => $source_two_name ), $source_two_properties ),
     59            $source_three_name       => array_merge( array( 'name' => $source_three_name ), $source_three_properties ),
     60            'core/post-meta'         => get_block_bindings_source( 'core/post-meta' ),
     61            'core/pattern-overrides' => get_block_bindings_source( 'core/pattern-overrides' ),
    7062        );
    7163
    7264        $registered = get_all_registered_block_bindings_sources();
    73         $this->assertSame( $expected, $registered );
     65        $this->assertEquals( $expected, $registered );
    7466    }
    7567
Note: See TracChangeset for help on using the changeset viewer.