Skip to content

Commit

Permalink
Updating classnames for wpGetBlockCssSelector.php tests
Browse files Browse the repository at this point in the history
Reverting changes to Tests_Theme_wpThemeJson that will need to be reinstated after WordPress#4619 merges
  • Loading branch information
ramonjd committed Jun 25, 2023
1 parent 5d2e137 commit e765f17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
41 changes: 13 additions & 28 deletions tests/phpunit/tests/theme/wpGetBlockCssSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ public function test_get_duotone_selector_via_selectors_api() {
$this->assertEquals( '.duotone-selector', $selector );
}

public function test_get_duotone_selector_via_experimental_property() {
$block_type = self::register_test_block(
'test/experimental-duotone-selector',
null,
array(
'color' => array(
'__experimentalDuotone' => '.experimental-duotone',
),
)
);

$selector = wp_get_block_css_selector( $block_type, 'filters.duotone' );
$this->assertEquals( '.experimental-duotone', $selector );
}

public function test_no_duotone_selector_set() {
$block_type = self::register_test_block(
'test/null-duotone-selector',
Expand Down Expand Up @@ -347,11 +332,11 @@ public function test_editor_only_root_selector() {
'test/editor-only-selectors',
array( 'root' => '.wp-custom-block-class' ),
null,
array( 'root' => '.editor-only.wp-custom-block-class' )
array( 'root' => '.wp-custom-block-class' )
);

$selector = wp_get_block_css_selector( $block_type, 'root' );
$this->assertEquals( '.editor-only.wp-custom-block-class', $selector );
$this->assertEquals( '.wp-custom-block-class', $selector );
}

public function test_editor_only_duotone_selector() {
Expand All @@ -364,12 +349,12 @@ public function test_editor_only_duotone_selector() {
),
null,
array(
'filters' => array( 'duotone' => '.editor-duotone-selector' ),
'filters' => array( 'duotone' => '.duotone-selector' ),
)
);

$selector = wp_get_block_css_selector( $block_type, 'filters.duotone' );
$this->assertEquals( '.editor-duotone-selector', $selector );
$this->assertEquals( '.duotone-selector', $selector );
}

public function test_editor_only_feature_selector() {
Expand All @@ -379,11 +364,11 @@ public function test_editor_only_feature_selector() {
'test/editor-feature-selector',
array( 'typography' => array( 'root' => '.typography' ) ),
null,
array( 'typography' => array( 'root' => '.editor-typography' ) )
array( 'typography' => array( 'root' => '.typography' ) )
);

$selector = wp_get_block_css_selector( $block_type, 'typography' );
$this->assertEquals( '.editor-typography', $selector );
$this->assertEquals( '.typography', $selector );
}

public function test_editor_only_feature_selector_shorthand() {
Expand All @@ -393,11 +378,11 @@ public function test_editor_only_feature_selector_shorthand() {
'test/editor-feature-selector',
array( 'typography' => '.typography' ),
null,
array( 'typography' => '.editor-typography' )
array( 'typography' => '.typography' )
);

$selector = wp_get_block_css_selector( $block_type, 'typography' );
$this->assertEquals( '.editor-typography', $selector );
$this->assertEquals( '.typography', $selector );
}

public function test_editor_only_subfeature_selector() {
Expand All @@ -407,11 +392,11 @@ public function test_editor_only_subfeature_selector() {
'test/editor-subfeature-selector',
array( 'typography' => array( 'fontSize' => '.font-size' ) ),
null,
array( 'typography' => array( 'fontSize' => '.editor-font-size' ) )
array( 'typography' => array( 'fontSize' => '.font-size' ) )
);

$selector = wp_get_block_css_selector( $block_type, 'typography.fontSize' );
$this->assertEquals( '.editor-font-size', $selector );
$this->assertEquals( '.font-size', $selector );
}

public function test_non_editor_subfeature_does_not_fall_back_to_editor_only_feature_selector() {
Expand All @@ -421,7 +406,7 @@ public function test_non_editor_subfeature_does_not_fall_back_to_editor_only_fea
'test/editor-subfeature-selector',
array( 'typography' => array( 'fontSize' => '.font-size' ) ),
null,
array( 'typography' => '.editor-font-size' )
array( 'typography' => '.font-size' )
);

$selector = wp_get_block_css_selector( $block_type, 'typography.fontSize', true );
Expand All @@ -435,11 +420,11 @@ public function test_unspecified_subfeature_falls_back_to_editor_only_feature_se
'test/editor-subfeature-selector',
array( 'typography' => '.typography' ),
null,
array( 'typography' => '.editor-typography' )
array( 'typography' => '.typography' )
);

$selector = wp_get_block_css_selector( $block_type, 'typography.fontSize', true );
$this->assertEquals( '.editor-typography', $selector );
$this->assertEquals( '.typography', $selector );
}
}

2 changes: 1 addition & 1 deletion tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public function test_get_stylesheet() {
);

$variables = "body{--wp--preset--color--grey: grey;--wp--preset--gradient--custom-gradient: linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%);--wp--preset--duotone--custom-duotone: url('#wp-duotone-custom-duotone');--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}";
$styles = 'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp-element-button, .wp-block-button__link{box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}.wp-block-group{background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}.wp-block-heading{color: #123456;}.wp-block-heading a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-post-excerpt{column-count: 2;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .components-placeholder{filter: var(--wp--preset--duotone--custom-duotone);}.wp-block-image img, .wp-block-image img{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';
$styles = 'body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}.wp-element-button, .wp-block-button__link{box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}.wp-block-group{background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;padding: 24px;}.wp-block-group a:where(:not(.wp-element-button)){color: #111;}.wp-block-heading{color: #123456;}.wp-block-heading a:where(:not(.wp-element-button)){background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a:where(:not(.wp-element-button)){background-color: #777;color: #555;}.wp-block-post-excerpt{column-count: 2;}.wp-block-image{margin-bottom: 30px;}.wp-block-image img, .wp-block-image .components-placeholder{filter: var(--wp--preset--duotone--custom-duotone);}.wp-block-image img, .wp-block-image .wp-block-image__crop-area{border-top-left-radius: 10px;border-bottom-right-radius: 1em;}';
$presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-custom-gradient-gradient-background{background: var(--wp--preset--gradient--custom-gradient) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}';
$all = $variables . $styles . $presets;
$this->assertSame( $all, $theme_json->get_stylesheet() );
Expand Down

0 comments on commit e765f17

Please sign in to comment.