CiviUnitTestCase - Remove redundant reset
authorTim Otten <totten@civicrm.org>
Fri, 16 Dec 2022 08:00:46 +0000 (00:00 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 7 Mar 2023 08:35:29 +0000 (00:35 -0800)
commit3090a72bdc4f58fac889bc2ef8521dca3f197f70
tree0b74698081305380ec11af5c66f1583e352a8435
parentf45dae8a8143b806a7ffea63e6e93b8e2bd1fc74
CiviUnitTestCase - Remove redundant reset

In CiviUnitTestCase, there are methods `setUpBeforeClass()` and `setUp()`.
Both methods reset the database unconditionally.

The general flow is like this:

  1: setUpBeforeClass();
  2: setUp(); testApple(); tearDown();
  3: setUp(); testBanana(); tearDown();
  4: setUp(); testCherry(); tearDown();
  5: tearDownAfterClass();

You might say: "Aha!  You need the call in `setUp`, because it runs more
frequently!" But not really - because `setUp()` has an extra guard
(`static::$dbInit`).  In effect, you perform DB-reset at step 1 -- and then
immediately again on step 2 -- and then never again (steps 3+4+5).

It is conceivable that a subclass might override these methods and inject
additional initialization steps -- in which case, this patch may affect
their behavior. We'll just have to run the test-suite to find out.

Final thought - If `static::$dbInit` were manipulated by other code, then
`setUp()` would be much more interesting.  But it's counterfactual -- grep
finds nothing that manipulates `dbInit`.
tests/phpunit/CiviTest/CiviUnitTestCase.php