[wp-trac] [WordPress Trac] #56793: Test tool and unit test improvements for 6.2
WordPress Trac
noreply at wordpress.org
Mon Dec 19 14:43:17 UTC 2022
#56793: Test tool and unit test improvements for 6.2
--------------------------------------+---------------------
Reporter: desrosj | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: 6.2
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+---------------------
Comment (by SergeyBiryukov):
In [changeset:"55006" 55006]:
{{{
#!CommitTicketReference repository="" revision="55006"
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.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56793#comment:58>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list