[wp-trac] [WordPress Trac] #27410: Clear object cache between tests

WordPress Trac noreply at wordpress.org
Sat Oct 18 12:26:32 UTC 2014


#27410: Clear object cache between tests
-------------------------------------+------------------------------
 Reporter:  rmccue                   |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Build/Test Tools         |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  close reporter-feedback  |     Focuses:
-------------------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:   => close reporter-feedback


Comment:

 > Should we just not load object caching when testing?

 We can't turn it off across the board, because many of our tests are for
 caching and cache invalidation.

 >  but it seems that clearing the whole of the object cache should be
 handled in tearDown automatically?

 Strictly speaking, we should run it during `setUp()`, to be absolutely
 sure that the cache is clean *before* each test is run. And, lo and
 behold, we do!
 https://core.trac.wordpress.org/browser/tags/4.0/tests/phpunit/includes/testcase.php#L39

 My guess is that you are not calling `parent::setUp()` in your test
 class's `setUp()` method. It should be the first thing anytime you
 override `WP_UnitTestCase::setUp()`. See eg
 https://core.trac.wordpress.org/browser/tags/4.0/tests/phpunit/tests/post.php.

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


More information about the wp-trac mailing list