Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Supports: Add additional PHP test coverage #34728

Closed
5 of 8 tasks
andrewserong opened this issue Sep 10, 2021 · 2 comments
Closed
5 of 8 tasks

Block Supports: Add additional PHP test coverage #34728

andrewserong opened this issue Sep 10, 2021 · 2 comments
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@andrewserong
Copy link
Contributor

andrewserong commented Sep 10, 2021

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!

@andrewserong andrewserong added [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Discussion For issues that are high-level and not yet ready to implement. labels Sep 10, 2021
@ramonjd
Copy link
Member

ramonjd commented Oct 26, 2022

Tests have been added for:

  • border.php
  • colors.php
  • layout.php
  • spacing.php
  • typography.php

@ramonjd ramonjd closed this as completed Oct 26, 2022
@andrewserong
Copy link
Contributor Author

Excellent, thanks for the update @ramonjd! Looks like we now have coverage for the main areas I was originally concerned about when I wrote up the issue 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

2 participants