ampproject / amp-wp

Enable AMP on your WordPress site, the WordPress way.
https://wordpress.org/plugins/amp/
GNU General Public License v2.0
1.79k stars 382 forks source link

Add WordPress timing tests #4576

Open schlessera opened 4 years ago

schlessera commented 4 years ago

Feature description

We don't have an obvious way right now to test anything that happens before the 'wp' hook, as we're using the WP_UnitTestCase. This leads to issues like the https://github.com/ampproject/amp-wp/issues/4525 because we can never catch any timing problems that can happen before the 'wp' action.

It might be worthwhile to set up a separate set of tests that use SHORT_INIT or some other hack to achieve the same thing) to be able to test our plugin against WordPress, but control which actions happen and test for earlier conflicts.

This would also allow us to add regression tests to fixes like the one for the issue above, where we can only test manually right now.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

westonruter commented 4 years ago

We could also just empty out the $wp_actions array.

schlessera commented 4 years ago

That won't have the same effect, as the actions will already have run and modified all the globals. If we want to catch timing issues, we have to run the tests with the real setup. otherwise we're testing something irrelevant and meaningless.