Make WordPress Core


Ignore:
Timestamp:
10/16/2015 09:04:12 PM (11 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/link/getNextCommentsLink.php

    r34802 r35225  
    99
    1010    public function test_page_should_respect_value_of_cpage_query_var() {
    11         $p = $this->factory->post->create();
     11        $p = self::$factory->post->create();
    1212        $this->go_to( get_permalink( $p ) );
    1313
     
    2626     */
    2727    public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
    28         $p = $this->factory->post->create();
     28        $p = self::$factory->post->create();
    2929        $this->go_to( get_permalink( $p ) );
    3030
Note: See TracChangeset for help on using the changeset viewer.