Changeset 57526 for trunk/tests/phpunit/tests/block-bindings/render.php
- Timestamp:
- 02/02/2024 08:22:11 PM (15 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-bindings/render.php
r57525 r57526 1 1 <?php 2 2 /** 3 * Unit tests covering the Block Bindings public API.3 * Tests for Block Bindings integration with block rendering. 4 4 * 5 5 * @package WordPress … … 9 9 * @group blocks 10 10 * @group block-bindings 11 *12 * @covers register_block_bindings_source13 11 */ 14 class WP_Block_Bindings_ Testextends WP_UnitTestCase {12 class WP_Block_Bindings_Render extends WP_UnitTestCase { 15 13 16 14 const SOURCE_NAME = 'test/source'; … … 20 18 21 19 /** 22 * Set up beforeeach test.20 * Tear down after each test. 23 21 * 24 22 * @since 6.5.0 25 23 */ 26 public function set_up() {24 public function tear_down() { 27 25 foreach ( get_all_registered_block_bindings_sources() as $source_name => $source_properties ) { 28 26 if ( str_starts_with( $source_name, 'test/' ) ) { … … 31 29 } 32 30 33 parent:: set_up();31 parent::tear_down(); 34 32 } 35 33 … … 39 37 * @ticket 60282 40 38 * 41 * @covers register_block_bindings_source39 * @covers ::register_block_bindings_source 42 40 */ 43 41 public function test_update_block_with_value_from_source() { … … 64 62 $result = $block->render(); 65 63 66 // Check if the block content was updated correctly.67 64 $this->assertEquals( $expected, $result, 'The block content should be updated with the value returned by the source.' ); 68 65 } … … 73 70 * @ticket 60282 74 71 * 75 * @covers register_block_bindings_source72 * @covers ::register_block_bindings_source 76 73 */ 77 74 public function test_passing_arguments_to_source() { … … 89 86 ); 90 87 91 $key = 'test'; 92 88 $value = 'test'; 93 89 $block_content = <<<HTML 94 <!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"test/source", "args": {"key": "$ key"}}}}} --><p>This should not appear</p><!-- /wp:paragraph -->90 <!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"test/source", "args": {"key": "$value"}}}}} --><p>This should not appear</p><!-- /wp:paragraph --> 95 91 HTML; 96 92 … … 98 94 $block = new WP_Block( $parsed_blocks[0] ); 99 95 100 $expected = "<p>The attribute name is 'content' and its binding has argument 'key' with value ' test'.</p>";96 $expected = "<p>The attribute name is 'content' and its binding has argument 'key' with value '$value'.</p>"; 101 97 $result = $block->render(); 102 98 103 // Check if the block content was updated correctly.104 99 $this->assertEquals( $expected, $result, 'The block content should be updated with the value returned by the source.' ); 105 100 }
Note: See TracChangeset
for help on using the changeset viewer.