Skip to:
Content

BuddyPress.org

Changeset 11736


Ignore:
Timestamp:
11/03/2017 07:35:01 PM (9 years ago)
Author:
boonebgorges
Message:

Implement factory() method for BP_UnitTestCase.

This method, present in WP since 4.4, allows static test methods to use
the same factory object as non-static methods. This in turn ensures that
iterators are kept consistent across a test run.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r11734 r11736  
    105105
    106106                parent::clean_up_global_scope();
     107        }
     108
     109        /**
     110         * Returns a factory that can be used across tests, even in static methods.
     111         *
     112         * @since 3.0
     113         *
     114         * @return BP_UnitTest_Factory
     115         */
     116        protected static function factory() {
     117                static $factory = null;
     118                if ( ! $factory ) {
     119                        $factory = new BP_UnitTest_Factory();
     120                }
     121                return $factory;
    107122        }
    108123
Note: See TracChangeset for help on using the changeset viewer.