Skip to content

Block Supports: Add additional PHP test coverage #34728

@andrewserong

Description

@andrewserong

What problem does this address?

Now that Block Supports are widely used for blocks in Gutenberg, let's investigate whether it'd be helpful to add additional block-level PHP tests to ensure the stability of the block supports and that we don't accidentally introduce regressions when we make updates to existing block supports.

What is your proposed solution?

The Block Supports PHP code that lives in lib/block-supports appears to currently have test coverage that mostly addresses theme.json support, via the tests in phpunit/class-wp-theme-json-test.php. For example, this ensures that given a theme.json file with a particular shape, the resulting generated CSS looks correct.

In addition to these tests, I propose that we look into adding PHPUnit tests to cover the server-side Block Supports behaviour that isn't directly related to the theme.json output. I included a few tests as part of the blockGap support in #33991, which added in a separate test file for spacing in phpunit/block-supports/spacing-test.php. Some examples of behaviour that could be good to test:

  • The gutenberg_apply_spacing_support function and that an individual block that opts into the spacing support receives the expected styles.
  • The __experimentalSkipSerialization flag in a block's supports, and test that a block that opts into that flag doesn't get the styles added.

For the purposes of this issue, let's review the key areas that could use additional test coverage in the following files under lib/block-supports/:

  • border.php
  • colors.php
  • dimensions.php
  • duotone.php
  • elements.php
  • layout.php
  • spacing.php
  • typography.php

This is more of an overview issue to track exploring whether it's appropriate to add tests to the above block supports, and track which areas we think would be good to focus on. If there are additional tests that we already have that I've missed, please let me know, or if you have strong feelings about PHP test coverage, I'm keen to hear what other folks think, too!

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Design ToolsTools that impact the appearance of blocks both to expand the number of tools and improve the experi[Type] DiscussionFor issues that are high-level and not yet ready to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions