[wp-trac] [WordPress Trac] #56740: set_up_before_class() / wpSetUpBeforeClass() are inconsistent and confusing

WordPress Trac noreply at wordpress.org
Wed Oct 5 22:28:48 UTC 2022


#56740: set_up_before_class() / wpSetUpBeforeClass() are inconsistent and confusing
------------------------------+------------------------------
 Reporter:  iandunn           |       Owner:  (none)
     Type:  enhancement       |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:  4.4
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------

Comment (by SergeyBiryukov):

 Some context from #55918:
 * `wpSetUpBeforeClass()` / `wpSetUpAfterClass()` should not be confused
 with the native PHPUnit methods that need to be replaced with WordPress'
 `snake_case` counterparts, 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()` / `wpSetUpAfterClass()` are used much more often
 in the test suite, though it should be possible to standardize on
 `set_up_before_class()` / `tear_down_after_class()` instead if that's
 preferred.
 * The main differences from `set_up_before_class()` /
 `tear_down_after_class()`:
  * `wpSetUpBeforeClass()` receives the `$factory` argument for ease of
 use.
  * Both `wpSetUpBeforeClass()` and `wpTearDownAfterClass()` don't need to
 call `self::commit_transaction()`.
 * At a glance, in the current test suite:
  * `wpSetUpBeforeClass()` / `wpSetUpAfterClass()` are used when the
 `$factory` argument is utilized.
  * `set_up_before_class()` / `tear_down_after_class()` are used when the
 `$factory` argument is not needed, for example to include some files.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56740#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list