Skip to content

Commit

Permalink
insert_hooked_blocks Test: Turn vars into class consts
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jan 16, 2024
1 parent d47dba8 commit 8669a32
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions tests/phpunit/tests/blocks/insertHookedBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,33 @@
* @group block-hooks
*/
class Tests_Blocks_InsertHookedBlocks extends WP_UnitTestCase {
const ANCHOR_BLOCK_TYPE = 'tests/anchor-block';

const HOOKED_BLOCK_TYPE = 'tests/hooked-block';
const HOOKED_BLOCK = array(
'blockName' => 'tests/different-hooked-block',
'attrs' => array(),
'innerContent' => array(),
);

const HOOKED_BLOCKS = array(
self::ANCHOR_BLOCK_TYPE => array(
'after' => array( self::HOOKED_BLOCK_TYPE ),
),
);

/**
* @ticket 60126
*
* @covers ::insert_hooked_blocks
*/
public function test_insert_hooked_blocks() {
$anchor_block_name = 'tests/anchor-block';
$anchor_block = array(

Check warning on line 35 in tests/phpunit/tests/blocks/insertHookedBlocks.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Equals sign not aligned correctly; expected 1 space but found 6 spaces
'blockName' => $anchor_block_name,
);

// Maybe move to class level and include other relative positions?
// And/or data provider?
$hooked_blocks = array(
$anchor_block_name => array(
'after' => array( 'tests/hooked-before' ),
),
'blockName' => self::ANCHOR_BLOCK_TYPE,
);

$actual = insert_hooked_blocks( $anchor_block, 'after', $hooked_blocks, array() );
$this->assertSame( array( 'tests/hooked-before' ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '<!-- wp:tests/hooked-before /-->', $actual );
$actual = insert_hooked_blocks( $anchor_block, 'after', self::HOOKED_BLOCKS, array() );
$this->assertSame( array( self::HOOKED_BLOCK_TYPE ), $anchor_block['attrs']['metadata']['ignoredHookedBlocks'] );
$this->assertSame( '<!-- wp:' . self::HOOKED_BLOCK_TYPE . ' /-->', $actual );
}
}

0 comments on commit 8669a32

Please sign in to comment.