WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/15/2015 04:43:37 AM (5 years ago)
Author:
wonderboymusic
Message:

Unit Tests: implement setUpBeforeClass() and tearDownAfterClass() on WP_UnitTestCase. Use late static binding (plus a gross fallback for PHP 5.2) to check if wpSetUpBeforeClass() or wpTearDownAfterClass() exist on the called class, and then call it and pass a static WP_UnitTest_Factory instance via Dependency Injection, if it exists.

This makes it way easier to add fixtures, and tear them down, without needing to instantiate WP_UnitTest_Factory in every class - removes the need to call commit_transaction() in each individual class.

See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r34655 r35186  
    11<?php
    2 
    3 require_once dirname( dirname( __FILE__ ) ) . '/db.php';
    42
    53/**
     
    1816
    1917    public static function setUpBeforeClass() {
     18        require_once( dirname( dirname( __FILE__ ) ) . '/db.php' );
     19       
    2020        self::$_wpdb = new wpdb_exposed_methods_for_testing();
    2121    }
Note: See TracChangeset for help on using the changeset viewer.