Automattic / Automattic/wordbless

How to test 'init' hook?

Open
#27 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
145
Forks
11
Avg merge
3m
Merged PRs (30d)
1

Description

As we run code in `wp-settings.php` we execute a lot of actions.

```php
do_action( 'plugins_loaded' );
do_action( 'sanitize_comment_cookies' );
do_action( 'setup_theme' );
do_action( 'after_setup_theme' );
do_action( 'init' );
do_action( 'wp_loaded' );
```

How to test code hooked to e.g. `after_setup_theme`?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading wp-settings.php and the listed lifecycle hooks, especially after_setup_theme and init, then inspect the existing PHPUnit test setup. The issue does not define a desired testing API or a concrete success case, so clarify the expected way to execute and assert hooked code before assessing what done means.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.