Tests: Correct a flaky wp_nonce_field() test.

The test for `wp_nonce_field()` with a custom action name verifies that the nonce value matches the one returned by `wp_create_nonce()` with the same action name.

The created nonce, in turn, depends on `wp_nonce_tick()`, which returns a different result in the first and the second half of the nonce's lifespan, one day by default:
* 00:00:01 to 12:00:00 — First tick
* 12:00:01 to 00:00:00 — Second tick

In practice, due to a delay between initializing data providers and running the actual tests, it is possible for the nonce tick to change in the process, for example if the test suite run starts at 11:59:30, and the affected test runs at 12:00:30, causing a test failure.

This commit reduces the chance of a race condition by moving the `wp_create_nonce()` call from the data provider into the test itself.

Includes wrapping long lines with the expected results for better readability.

Follow-up to [54420].

Props NekoJonez, SergeyBiryukov.
See #56793.
Built from https://develop.svn.wordpress.org/trunk@55006


git-svn-id: http://core.svn.wordpress.org/trunk@54539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-12-19 14:45:18 +00:00
parent 0f323130f7
commit a65e37770d

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55005';
$wp_version = '6.2-alpha-55006';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.