Changeset 35186 for trunk/tests/phpunit/includes/testcase.php
- Timestamp:
- 10/15/2015 04:43:37 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r35136 r35186 19 19 */ 20 20 protected $factory; 21 22 protected static $static_factory; 23 24 public static function get_called_class() { 25 if ( function_exists( 'get_called_class' ) ) { 26 return get_called_class(); 27 } 28 29 // PHP 5.2 only 30 $backtrace = debug_backtrace(); 31 // [0] WP_UnitTestCase::get_called_class() 32 // [1] WP_UnitTestCase::setUpBeforeClass() 33 if ( 'call_user_func' === $backtrace[2]['function'] ) { 34 return $backtrace[2]['args'][0][0]; 35 } 36 return $backtrace[2]['class']; 37 } 38 39 public static function setUpBeforeClass() { 40 parent::setUpBeforeClass(); 41 42 $c = self::get_called_class(); 43 if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { 44 return; 45 } 46 47 if ( ! self::$static_factory ) { 48 self::$static_factory = new WP_UnitTest_Factory(); 49 } 50 51 call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$static_factory ); 52 53 self::commit_transaction(); 54 } 55 56 public static function tearDownAfterClass() { 57 parent::tearDownAfterClass(); 58 59 $c = self::get_called_class(); 60 if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { 61 return; 62 } 63 64 call_user_func( array( $c, 'wpTearDownAfterClass' ) ); 65 66 self::commit_transaction(); 67 } 21 68 22 69 function setUp() {
Note: See TracChangeset
for help on using the changeset viewer.