Opened 4 years ago
Last modified 20 months ago
#56740 new enhancement
set_up_before_class() / wpSetUpBeforeClass() are inconsistent and confusing
| Reported by: | iandunn | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Build/Test Tools | Version: | 4.4 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
There was some discussion in #55918 about standardizing on either set_up_before_class()/set_up_after_class() or wpSetUpBeforeClass()/wpSetUpAfterClass(). That would bring consistency, and help reduce the confusion that exists around those functions. That applies to the tear down functions as well.
See comment:7:ticket:55918 (and replies to it)
See https://wordpress.slack.com/archives/C03B0H5J0/p1660782746785649
See https://wordpress.slack.com/archives/C03B0H5J0/p1661876947032299
The wp... variants were introduced in r35186.
If a change is made here (and probably even if one isn't), it'd be good to update the handbook page to explain which functions folks should use, and any caveats.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Some context from #55918:
wpSetUpBeforeClass()/wpTearDownAfterClass()should not be confused with the native PHPUnit methods that need to be replaced with WordPress'snake_casecounterparts, as the tests would not pass across all supported PHP and PHPUnit versions otherwise:setUpBeforeClass()(native PHPUnit method) →set_up_before_class()(WP method)tearDownAfterClass()(native PHPUnit method) →tear_down_after_class()(WP method)wpSetUpBeforeClass()/wpTearDownAfterClass()are used much more often in the test suite, though it should be possible to standardize onset_up_before_class()/tear_down_after_class()instead if that's preferred.set_up_before_class()/tear_down_after_class():wpSetUpBeforeClass()receives the$factoryargument for ease of use.wpSetUpBeforeClass()andwpTearDownAfterClass()don't need to callself::commit_transaction().wpSetUpBeforeClass()/wpTearDownAfterClass()are used when the$factoryargument is utilized.set_up_before_class()/tear_down_after_class()are used when the$factoryargument is not needed, for example to include some files.