Title: WP_Site_Health_Auto_Updates::test_constants
Published: May 7, 2019
Last modified: August 20, 2026

---

# WP_Site_Health_Auto_Updates::test_constants( string $constant, bool|string|array $value ): array|null

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#wp--skip-link--target)

Tests if auto-updates related constants are set correctly.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#parameters)󠁿

 `$constant`stringrequired

The name of the constant to check.

`$value`bool|string|arrayrequired

The value that the constant should be, if set, or an array of acceptable values.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#return)󠁿

 array|null The test results if there are any constants set incorrectly, or null
if the test passed.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#source)󠁿

    ```php
    public function test_constants( $constant, $value ) {
    	$acceptable_values = (array) $value;

    	if ( defined( $constant ) && ! in_array( constant( $constant ), $acceptable_values, true ) ) {
    		return array(
    			'description' => sprintf(
    				/* translators: 1: Name of the constant used. 2: Value of the constant used. */
    				__( 'The %1$s constant is defined as %2$s' ),
    				"<code>$constant</code>",
    				'<code>' . esc_html( var_export( constant( $constant ), true ) ) . '</code>'
    			),
    			'severity'    => 'fail',
    		);
    	}

    	return null;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-site-health-auto-updates.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-wp-site-health-auto-updates.php#L72)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-site-health-auto-updates.php#L72-L88)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  |

| Used by | Description | 
| [WP_Site_Health_Auto_Updates::run_tests()](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/run_tests/)`wp-admin/includes/class-wp-site-health-auto-updates.php` |

Runs tests to determine if auto-updates can run.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_site_health_auto_updates/test_constants/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.1](https://developer.wordpress.org/reference/since/5.5.1/) | The `$value` parameter can accept an array. | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_site_health_auto_updates%2Ftest_constants%2F)
before being able to contribute a note or feedback.