Opened 9 years ago
Closed 9 years ago
#41561 closed enhancement (fixed)
Remove usage of DOING_AJAX in the test suite
| Reported by: | johnbillion | Owned by: | johnbillion |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | needs-unit-tests |
| Cc: | Focuses: |
Description
In the test suite, several tests define DOING_AJAX to true. This effectively pollutes the tests which follow them, and prevent any other tests from operating in a non-Ajax state when they need to (for example, Tests_WP_Customize_Manager::test_not_doing_ajax()).
Instances of DOING_AJAX should be replaced by use of a filter, for example add_filter( 'wp_doing_ajax', '__return_true' ).
Attachments (3)
Change History (14)
#2
@
9 years ago
- Keywords has-patch dev-feedback added; needs-patch removed
I was looking on simple tickets to start with unit tests so this was perfect.
I checked and with this changes there was no problems with the tests :-)
This ticket was mentioned in Slack in #core by mte90. View the logs.
9 years ago
#4
@
9 years ago
- Keywords dev-feedback removed
- Milestone Awaiting Review → 4.9
@Mte90 Looks good!
- The
test_not_doing_ajax()test can useadd_filter( 'wp_doing_ajax', '__return_false' )to force a non-Ajax request, and then remove themarkTestSkippedcall. - Does this cover all instances of
DOING_AJAXin the test suite?
#5
@
9 years ago
- I will do a new patch for that asap
- I searched in all the code about the use of the constant and replace with the function :-)
#8
@
9 years ago
I am not sure the current implementation resolves the issue properly. Adding a filter in the static setUpBeforeClass method will still exist in test cases that are run later. I advise putting the hook into the setUp method like the wp_die_ajax_handler hook.
I think this would also be more in line with the WP_UnitTestCase class as it backs up all hooks in the setUp method.
#9
@
9 years ago
- Keywords needs-unit-tests added; has-patch removed
- Resolution fixed
- Status closed → reopened
Re-opening as per comment above.
#10
@
9 years ago
41561.3.diff moves the filter from setUpBeforeClass() to setUp() in WP_Ajax_UnitTestCase. All other occurrences are in the correct location.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Previously: #25669