[wp-trac] [WordPress Trac] #29712: Restore $current_user between unit tests

WordPress Trac noreply at wordpress.org
Fri Sep 19 19:18:25 UTC 2014


#29712: Restore $current_user between unit tests
-------------------------+-----------------------------
 Reporter:  mnelson4     |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 If the $current_user global is changed during a unit test, that change is
 persisted to all subsequent unit tests, making the tests dependent on
 order. (eg, meaning that if I change the $current_user to be an admin
 during a test, they're forevermore an admin. So a later test that assumes
 the $current_user is the default blank user will probably fail, even
 though that other unit test could pass when ran in isolation.)
 The solution I have is to just clone the $current_user on the first unit
 test and save it somewhere; and then after each unit test, restore the
 $current_user to be a clone of the saved original

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29712>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list