- Timestamp:
- 01/25/2024 01:46:49 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/getHookedBlockMarkup.php
r57172 r57354 12 12 */ 13 13 class Tests_Blocks_GetHookedBlockMarkup extends WP_UnitTestCase { 14 const HOOKED_BLOCK_TYPE = 'tests/hooked-block'; 15 const HOOKED_BLOCK = array( 16 'blockName' => 'tests/different-hooked-block', 17 'attrs' => array(), 18 'innerContent' => array(), 19 ); 20 14 21 /** 22 * @ticket 59572 15 23 * @ticket 60008 24 * @ticket 60126 16 25 * 17 26 * @covers ::get_hooked_block_markup … … 22 31 ); 23 32 24 $actual = get_hooked_block_markup( $anchor_block, 'tests/hooked-block' ); 25 $this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ); 26 $this->assertSame( '<!-- wp:tests/hooked-block /-->', $actual ); 33 $actual = get_hooked_block_markup( self::HOOKED_BLOCK, self::HOOKED_BLOCK_TYPE, $anchor_block ); 34 $this->assertSame( 35 array( self::HOOKED_BLOCK_TYPE ), 36 $anchor_block['attrs']['metadata']['ignoredHookedBlocks'], 37 "Hooked block type wasn't added to ignoredHookedBlocks metadata." 38 ); 39 $this->assertSame( 40 '<!-- wp:' . self::HOOKED_BLOCK['blockName'] . ' /-->', 41 $actual, 42 "Markup for hooked block wasn't generated correctly." 43 ); 27 44 } 28 45 29 46 /** 47 * @ticket 59572 30 48 * @ticket 60008 49 * @ticket 60126 31 50 * 32 51 * @covers ::get_hooked_block_markup … … 37 56 'attrs' => array( 38 57 'metadata' => array( 39 'ignoredHookedBlocks' => array( 'tests/hooked-block'),58 'ignoredHookedBlocks' => array( self::HOOKED_BLOCK_TYPE ), 40 59 ), 41 60 ), 42 61 ); 43 62 44 $actual = get_hooked_block_markup( $anchor_block, 'tests/hooked-block' ); 45 $this->assertSame( array( 'tests/hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ); 46 $this->assertSame( '', $actual ); 63 $actual = get_hooked_block_markup( self::HOOKED_BLOCK, self::HOOKED_BLOCK_TYPE, $anchor_block ); 64 $this->assertSame( 65 array( self::HOOKED_BLOCK_TYPE ), 66 $anchor_block['attrs']['metadata']['ignoredHookedBlocks'], 67 "ignoredHookedBlocks metadata shouldn't have been modified." 68 ); 69 $this->assertSame( 70 '', 71 $actual, 72 "No markup should've been generated for ignored hooked block." 73 ); 47 74 } 48 75 49 76 /** 77 * @ticket 59572 50 78 * @ticket 60008 79 * @ticket 60126 51 80 * 52 81 * @covers ::get_hooked_block_markup 53 82 */ 54 83 public function test_get_hooked_block_markup_adds_to_ignored_hooked_blocks() { 84 $other_hooked_block_type = 'tests/other-hooked-block'; 85 $other_hooked_block = array( 86 'blockName' => $other_hooked_block_type, 87 'attrs' => array(), 88 'innerContent' => array(), 89 ); 90 55 91 $anchor_block = array( 56 92 'blockName' => 'tests/anchor-block', 57 93 'attrs' => array( 58 94 'metadata' => array( 59 'ignoredHookedBlocks' => array( 'tests/hooked-block'),95 'ignoredHookedBlocks' => array( self::HOOKED_BLOCK_TYPE ), 60 96 ), 61 97 ), 62 98 ); 63 99 64 $actual = get_hooked_block_markup( $anchor_block, 'tests/other-hooked-block' ); 65 $this->assertSame( array( 'tests/hooked-block', 'tests/other-hooked-block' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] ); 66 $this->assertSame( '<!-- wp:tests/other-hooked-block /-->', $actual ); 100 $actual = get_hooked_block_markup( $other_hooked_block, $other_hooked_block_type, $anchor_block ); 101 $this->assertSame( 102 array( self::HOOKED_BLOCK_TYPE, $other_hooked_block_type ), 103 $anchor_block['attrs']['metadata']['ignoredHookedBlocks'], 104 "Newly hooked block should've been added to ignoredHookedBlocks metadata while retaining previously ignored one." 105 ); 106 $this->assertSame( 107 '<!-- wp:' . $other_hooked_block_type . ' /-->', 108 $actual, 109 "Markup for newly hooked block should've been generated." 110 ); 67 111 } 68 112 }
Note: See TracChangeset
for help on using the changeset viewer.