Changeset 57562 for trunk/tests/phpunit/tests/block-bindings/register.php
- Timestamp:
- 02/08/2024 08:55:18 AM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-bindings/register.php
r57526 r57562 12 12 class Tests_Block_Bindings_Register extends WP_UnitTestCase { 13 13 14 const TEST_SOURCE_NAME = 'test/source'; 15 const TEST_SOURCE_PROPERTIES = array( 16 'label' => 'Test source', 17 ); 14 public static $test_source_name = 'test/source'; 15 public static $test_source_properties = array(); 16 17 /** 18 * Set up before each test. 19 * 20 * @since 6.5.0 21 */ 22 public function set_up() { 23 parent::set_up(); 24 25 self::$test_source_properties = array( 26 'label' => 'Test source', 27 'get_value_callback' => function () { 28 return 'test-value'; 29 }, 30 ); 31 } 18 32 19 33 /** … … 40 54 * @covers ::get_all_registered_block_bindings_sources 41 55 * @covers ::get_block_bindings_source 56 * @covers WP_Block_Bindings_Source::__construct 42 57 */ 43 58 public function test_get_all_registered() { 44 59 $source_one_name = 'test/source-one'; 45 $source_one_properties = self:: TEST_SOURCE_PROPERTIES;60 $source_one_properties = self::$test_source_properties; 46 61 register_block_bindings_source( $source_one_name, $source_one_properties ); 47 62 48 63 $source_two_name = 'test/source-two'; 49 $source_two_properties = self:: TEST_SOURCE_PROPERTIES;64 $source_two_properties = self::$test_source_properties; 50 65 register_block_bindings_source( $source_two_name, $source_two_properties ); 51 66 52 67 $source_three_name = 'test/source-three'; 53 $source_three_properties = self:: TEST_SOURCE_PROPERTIES;68 $source_three_properties = self::$test_source_properties; 54 69 register_block_bindings_source( $source_three_name, $source_three_properties ); 55 70 56 71 $expected = array( 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 ),72 $source_one_name => new WP_Block_Bindings_Source( $source_one_name, $source_one_properties ), 73 $source_two_name => new WP_Block_Bindings_Source( $source_two_name, $source_two_properties ), 74 $source_three_name => new WP_Block_Bindings_Source( $source_three_name, $source_three_properties ), 60 75 'core/post-meta' => get_block_bindings_source( 'core/post-meta' ), 61 76 'core/pattern-overrides' => get_block_bindings_source( 'core/pattern-overrides' ), … … 73 88 * @covers ::register_block_bindings_source 74 89 * @covers ::unregister_block_bindings_source 90 * @covers WP_Block_Bindings_Source::__construct 75 91 */ 76 92 public function test_unregister_block_source() { 77 register_block_bindings_source( self:: TEST_SOURCE_NAME, self::TEST_SOURCE_PROPERTIES);93 register_block_bindings_source( self::$test_source_name, self::$test_source_properties ); 78 94 79 $result = unregister_block_bindings_source( self:: TEST_SOURCE_NAME);80 $this->assert Same(81 array_merge(82 array( 'name' => self::TEST_SOURCE_NAME ),83 self:: TEST_SOURCE_PROPERTIES95 $result = unregister_block_bindings_source( self::$test_source_name ); 96 $this->assertEquals( 97 new WP_Block_Bindings_Source( 98 self::$test_source_name, 99 self::$test_source_properties 84 100 ), 85 101 $result
Note: See TracChangeset
for help on using the changeset viewer.