summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit
diff options
context:
space:
mode:
authorRobert Anderson <noisysocks@git.wordpress.org>2022-01-04 05:37:25 +0000
committerRobert Anderson <noisysocks@git.wordpress.org>2022-01-04 05:37:25 +0000
commitbd08b221273b8b367a18fef8c9efb873819ac89d (patch)
treed2f2b30db4f86ed471e39ce524b5b9f9f37ed1e9 /tests/phpunit
parent568bef09855f2784d1f0221703522fe2632af255 (diff)
downloadwordpress-bd08b221273b8b367a18fef8c9efb873819ac89d.tar.gz
wordpress-bd08b221273b8b367a18fef8c9efb873819ac89d.zip
Update @wordpress packages
Update packages to include these bug fixes from Gutenberg: - Site Logo: Add option to set site icon from Site Logo block - Navigation: Enable even more compact setup state. - Remove template parts from post content inserter an __unstable filter - Template Editor Mode: Hide editor mode switcher - Avoid using CSS variables for block gap styles - Try to fix auto resizing in template part focus mode - Lower the specificity of font size CSS Custom Properties in the editor - Site icon: Fix site icon styling to display non-square site icons within a square button - [Site Editor]: Register block editor shortcuts - Update regex to handle 404 template slug - Site Editor: Remove dead code - [Block Editor]: Restrict delete multi selected blocks shortcut - Fix: Gradients are not being applied by class - Update: Make the global styles subtitles font smaller - Post Content/Title: Reflect changes when previewing post - ServerSideRender: Fix loading state - [Block Library]: Fix editable post blocks in Query Loop with zero queryId - Post Excerpt: Fix previews - WP59: Contextualize "Export" string to differentiate it from other occurrences in WP Core - Tools Panel: Fix race conditions caused by conditionally displayed ToolsPanelItems - ToolsPanel: Allow items to register when panelId is null - Font Size Picker: Allow non-integers as simple CSS values and in hints - [Components - FontSizePicker]: Use incremental sequence of numbers as labels for the available font-sizes at the segmented control (conditionally) See #54487. git-svn-id: https://develop.svn.wordpress.org/trunk@52434 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/tests/block-supports/spacing.php138
-rw-r--r--tests/phpunit/tests/rest-api/rest-settings-controller.php1
-rw-r--r--tests/phpunit/tests/theme/wpThemeJson.php52
3 files changed, 45 insertions, 146 deletions
diff --git a/tests/phpunit/tests/block-supports/spacing.php b/tests/phpunit/tests/block-supports/spacing.php
deleted file mode 100644
index 9215716708..0000000000
--- a/tests/phpunit/tests/block-supports/spacing.php
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-/**
- * @group block-supports
- */
-class Tests_Block_Supports_Spacing extends WP_UnitTestCase {
- private $sample_block_content = '<div class="wp-block-test-block">Test</div>';
- private $test_gap_block_value = array();
- private $test_gap_block_args = array();
-
- function set_up() {
- parent::set_up();
-
- $this->test_gap_block_value = array(
- 'blockName' => 'test/test-block',
- 'attrs' => array(
- 'style' => array(
- 'spacing' => array(
- 'blockGap' => '3em',
- ),
- ),
- ),
- );
-
- $this->test_gap_block_args = array(
- 'api_version' => 2,
- 'supports' => array(
- 'spacing' => array(
- 'blockGap' => true,
- ),
- ),
- );
- }
-
- function tear_down() {
- unregister_block_type( 'test/test-block' );
-
- parent::tear_down();
- }
-
- function test_spacing_gap_block_support_renders_block_inline_style() {
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- $this->sample_block_content,
- $this->test_gap_block_value
- );
-
- $this->assertSame(
- '<div style="--wp--style--block-gap: 3em" class="wp-block-test-block">Test</div>',
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_renders_block_inline_style_with_inner_tag() {
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- '<div class="wp-test-block"><p style="color: red;">Test</p></div>',
- $this->test_gap_block_value
- );
-
- $this->assertSame(
- '<div style="--wp--style--block-gap: 3em" class="wp-test-block"><p style="color: red;">Test</p></div>',
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_renders_block_inline_style_with_no_other_attributes() {
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- '<div><p>Test</p></div>',
- $this->test_gap_block_value
- );
-
- $this->assertSame(
- '<div style="--wp--style--block-gap: 3em"><p>Test</p></div>',
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_renders_appended_block_inline_style() {
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- '<div class="wp-test-block" style="background: green;"><p style="color: red;">Test</p></div>',
- $this->test_gap_block_value
- );
-
- $this->assertSame(
- '<div class="wp-test-block" style="--wp--style--block-gap: 3em; background: green;"><p style="color: red;">Test</p></div>',
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_does_not_render_style_when_support_is_false() {
- $this->test_gap_block_args['supports']['spacing']['blockGap'] = false;
-
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- $this->sample_block_content,
- $this->test_gap_block_value
- );
-
- $this->assertEquals(
- $this->sample_block_content,
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_does_not_render_style_when_gap_is_null() {
- $this->test_gap_block_value['attrs']['style']['spacing']['blockGap'] = null;
- $this->test_gap_block_args['supports']['spacing']['blockGap'] = true;
-
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- $this->sample_block_content,
- $this->test_gap_block_value
- );
-
- $this->assertEquals(
- $this->sample_block_content,
- $render_output
- );
- }
-
- function test_spacing_gap_block_support_does_not_render_style_when_gap_is_illegal_value() {
- $this->test_gap_block_value['attrs']['style']['spacing']['blockGap'] = '" javascript="alert("hello");';
- $this->test_gap_block_args['supports']['spacing']['blockGap'] = true;
-
- register_block_type( 'test/test-block', $this->test_gap_block_args );
- $render_output = wp_render_spacing_gap_support(
- $this->sample_block_content,
- $this->test_gap_block_value
- );
-
- $this->assertEquals(
- $this->sample_block_content,
- $render_output
- );
- }
-}
diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php
index bb9a4bbdb6..fe99fccfa8 100644
--- a/tests/phpunit/tests/rest-api/rest-settings-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php
@@ -108,6 +108,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
'posts_per_page',
'default_ping_status',
'default_comment_status',
+ 'site_icon', // Registered in wp-includes/blocks/site-logo.php
);
if ( ! is_multisite() ) {
diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php
index eefa1ca26a..6d92c3741b 100644
--- a/tests/phpunit/tests/theme/wpThemeJson.php
+++ b/tests/phpunit/tests/theme/wpThemeJson.php
@@ -419,18 +419,11 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
'spacing' => array(
'blockGap' => '1em',
),
- 'blocks' => array(
- 'core/columns' => array(
- 'spacing' => array(
- 'blockGap' => '24px',
- ),
- ),
- ),
),
)
);
- $expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.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; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }.wp-block-columns{--wp--style--block-gap: 24px;}';
+ $expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.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; }.wp-site-blocks > * { margin-top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }';
$this->assertSame( $expected, $theme_json->get_stylesheet() );
$this->assertSame( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );
}
@@ -2348,4 +2341,47 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
$this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
}
+ /**
+ * @ticket 54487
+ */
+ public function test_sanitization() {
+ $theme_json = new WP_Theme_JSON(
+ array(
+ 'version' => 2,
+ 'styles' => array(
+ 'spacing' => array(
+ 'blockGap' => 'valid value',
+ ),
+ 'blocks' => array(
+ 'core/group' => array(
+ 'spacing' => array(
+ 'margin' => 'valid value',
+ 'blockGap' => 'invalid value',
+ ),
+ ),
+ ),
+ ),
+ )
+ );
+
+ $actual = $theme_json->get_raw_data();
+ $expected = array(
+ 'version' => 2,
+ 'styles' => array(
+ 'spacing' => array(
+ 'blockGap' => 'valid value',
+ ),
+ 'blocks' => array(
+ 'core/group' => array(
+ 'spacing' => array(
+ 'margin' => 'valid value',
+ ),
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEqualSetsWithIndex( $expected, $actual );
+ }
+
}