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

Add PHPUnit tests for mu-plugins #204

Open
wants to merge 26 commits into
base: trunk
Choose a base branch
from
Open

Conversation

dd32
Copy link
Member

@dd32 dd32 commented May 12, 2022

This PR adds unit tests to #173

I've separated it due to the amount of work I had to do to make it work.

wp_get_environment_type() is not exactly designed to be used during unit testing, and while it allows for it to be bypassed, wp-env forces phpunit to be a local environment.

Draft while I figure out if it's viable.

@dd32
Copy link
Member Author

dd32 commented May 16, 2022

Aside from the hacky sed "/WP_ENVIRONMENT_TYPE/d" -i .... within the action setup, I think this is working well enough that it's worth committing and expanding upon over time for other plugins.

An upstream issue to allow removing the hacky hack above is here: WordPress/gutenberg#41083

@dd32 dd32 marked this pull request as ready for review May 16, 2022 07:02
@@ -21,7 +21,10 @@
"composer/installers": "~1.0"
},
"require-dev": {
"wporg/wporg-repo-tools": "dev-trunk"
"phpunit/phpunit": "^9.5",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this is actually needed here, I suspect it's not, as it would only be needed if you're running phpunit outside of wp-env.

The below wp-phpunit & yoast deps are however required.

<?php

class Test_CDN_Assets extends WP_UnitTestCase {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a setUp/tearDown method to check/reset the environmental WP_ENVIRONMENT_TYPE value.

@dd32 dd32 deleted the branch WordPress:trunk August 22, 2023 03:00
@dd32 dd32 closed this Aug 22, 2023
@dd32 dd32 reopened this Aug 22, 2023
@dd32 dd32 changed the base branch from add/cdn-plugin to trunk August 22, 2023 03:05
@dd32
Copy link
Member Author

dd32 commented Aug 22, 2023

@dd32 dd32 deleted the branch WordPress:trunk 6 minutes ago

Ha. No I didn't. I changed the base target of this PR, the old base branch for the PR was deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant