Make WordPress Core


Ignore:
Timestamp:
10/16/2015 09:04:12 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: one $factory to rule them all, and it shall be static.

Using more than one instance of WP_UnitTest_Factory causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use setUpBeforeClass, we were creating ad hoc instances. To avoid that, we were injecting one static instance via Dependency Injection in wpSetUpBeforeClass. All tests should really use the static instance, so we will remove the instance prop $factory.

Replace $this->factory with self::$factory over 2000 times.
Rewrite all of the tests that were hard-coding dynamic values.

#YOLOFriday

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/getSpaceUsed.php

    r34518 r35225  
    2323
    2424    function test_get_space_used_switched_site() {
    25         $blog_id = $this->factory->blog->create();
     25        $blog_id = self::$factory->blog->create();
    2626        switch_to_blog( $blog_id );
    2727
     
    3131        while ( 0 != get_space_used() ) {
    3232            restore_current_blog();
    33             $blog_id = $this->factory->blog->create();
     33            $blog_id = self::$factory->blog->create();
    3434            switch_to_blog( $blog_id );
    3535        }
     
    5959        $space_used = get_space_used();
    6060
    61         $blog_id = $this->factory->blog->create();
     61        $blog_id = self::$factory->blog->create();
    6262        switch_to_blog( $blog_id );
    6363
     
    6767        while ( 0 != get_space_used() ) {
    6868            restore_current_blog();
    69             $blog_id = $this->factory->blog->create();
     69            $blog_id = self::$factory->blog->create();
    7070            switch_to_blog( $blog_id );
    7171        }
Note: See TracChangeset for help on using the changeset viewer.