Skip to content

Commit

Permalink
Fixed tests. Issue with asserting equals on cssClassName as it varies…
Browse files Browse the repository at this point in the history
… between WP versions slightly
  • Loading branch information
colinmurphy committed Dec 31, 2024
1 parent e4b826d commit 05c8e35
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions tests/unit/CoreGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public function test_retrieve_core_image_fields_attributes(): void {
$this->assertEmpty( $block['parentClientId'], 'There should be no parentClientId' );
$this->assertNotEmpty( $block['renderedHtml'], 'The renderedHtml should be present' );


// Check child blocks
$clientId = $block['clientId'];
$childBlock1 = $node['editorBlocks'][1];
Expand All @@ -175,23 +174,17 @@ public function test_retrieve_core_image_fields_attributes(): void {
$this->assertEquals('core/paragraph', $childBlock1['name'], 'Child block 2 should be a core/paragraph' );

// Check attributes
$this->assertEquals(
[
"align" => null,
"backgroundColor" => null,
"borderColor" => null,
"className" => "test-group-class is-style-default",
"cssClassName" => "wp-block-group test-group-class is-style-default is-content-justification-center is-layout-flex wp-container-7",
"fontFamily" => null,
"fontSize" => null,
"gradient" => null,
"layout" => "{\"type\":\"flex\",\"flexWrap\":\"wrap\",\"justifyContent\":\"center\"}",
"lock" => null,
'style' => null,
"tagName" => "header",
"textColor" => null
],
$node['editorBlocks'][0]['attributes']
);
$blockAttributes = $node['editorBlocks'][0]['attributes'];
$this->assertEquals(null, $blockAttributes['align']);
$this->assertEquals(null, $blockAttributes['backgroundColor']);
$this->assertEquals(null, $blockAttributes['borderColor']);
$this->assertEquals('test-group-class is-style-default', $blockAttributes['className']);
$this->assertStringContainsString('wp-block-group test-group-class is-style-default', $blockAttributes['cssClassName']); // Class name varies slightly between WP versions
$this->assertEquals(null, $blockAttributes['fontFamily']);
$this->assertEquals(null, $blockAttributes['fontSize']);
$this->assertEquals("{\"type\":\"flex\",\"flexWrap\":\"wrap\",\"justifyContent\":\"center\"}", $blockAttributes['layout']);
$this->assertEquals(null, $blockAttributes['style']);
$this->assertEquals('header', $blockAttributes['tagName']);
$this->assertEquals(null, $blockAttributes['textColor']);
}
}

0 comments on commit 05c8e35

Please sign in to comment.