-
Notifications
You must be signed in to change notification settings - Fork 39
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 feature tests for checking plugin with addon enabled #518
base: trunk
Are you sure you want to change the base?
Conversation
ernilambar
commented
Jul 11, 2024
- Add feature tests with addon enabled (which includes new category and extra checks under that category)
Note: Behat tests are passing in my local setup with following specs.
|
Problem I am facing is classes on main plugin are not loading in the addon. Since WordPress not necessarily loads plugin files in our required order, how can I make sure that all classes of main plugin are available in the addon? CC @swissspidy |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
May be we should also add instructions in our docs on how to create addon for Plugin Check. |
Yeah simply defining the classes like that would be error prone. First, you'll want to use the Second, I would recommending moving the classes to separate files and then load them only when needed and when you know the parent classes exist. For example like so: add_filter(
'wp_plugin_check_checks',
function ( array $checks ) {
require_once './class-prohibited-text-check.php';
require_once './class-postsperpage-check.php';
return array_merge(
$checks,
array(
'prohibited_text' => new Prohibited_Text_Check(),
'postsperpage' => new PostsPerPage_Check(),
)
);
}
); |
Yeah @davidperezgar brought that up too. First we can start small, explaining the filters and giving a short example. We can reuse some of the code you're writing here for that. Not really urgent though, as I doubt there is huge demand for writing those 😄 |
Yes! That would be very helpful. |
8f74139
to
3259602
Compare
When I |
That sounds odd 🤔 Sounds like some debugging is in order |
3259602
to
697526f
Compare
@swissspidy I tried this to reproduce this in separate setup. After first command run, those checks are not included until I delete file |
So it's an issue with Plugin Check / the Want me to take a look at it to see if I can find the issue, or what's the next step? |
Yes, it does not seem to be related to Behat test. I tried to debug but could not find the exact issue. May be you can give a shot to find issue quicker as you are more familiar with the architecture 😊 |
Well, I'm not that familiar with that part 😅 The gist is that From what I can see, this hack is used so we can perform runtime checks for a plugin without the plugin having to be active on the site. But not entirely sure. When I activate Related: #153 |
I removed |
It's still needed and used by |
Behat tests are not passing. |
Yes. See #518 (comment) above and related conversation. That needs to be fixed first. |
fed9f63
to
82dc502
Compare
I have created separate feature file to pass the feature test. For blocker, I have created separate issue for tracking. #555 |
But separating the tests like this now gives the false impression that it works, when in reality it actually doesn't (well, unless you delete the drop-in between runs). The object-cache drop-in simply prevents add-ons from easily integrating with PCP, due to the change in execution/loading order. That blocks this PR. |
So, is it ok? |
No, IMHO this PR is currently blocked because the feature it is testing is not actually working as expected. It is blocked by #555 |