Make WordPress Core

Ticket #33968: awesome-2.diff

File awesome-2.diff, 740.9 KB (added by nerrad, 10 years ago)

expands on awesome.diff and implements factory() to grab the WP_UnitTestFactory instance for all wp tests. (Search and Replace self::$factory with self::factory()

  • .gitignore

    diff --git .gitignore .gitignore
    index dd18e54..b7ac88d 100644
     
    44wp-config.php
    55wp-tests-config.php
    66.htaccess
    7 
     7.idea
    88# Files and folders related to build/test tools
    99/phpunit.xml
    1010/tests/phpunit/data/plugins/wordpress-importer
  • tests/phpunit/includes/testcase-ajax.php

    diff --git tests/phpunit/includes/testcase-ajax.php tests/phpunit/includes/testcase-ajax.php
    index 6296ced..3227fa6 100644
    abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { 
    7575                error_reporting( $this->_error_level & ~E_WARNING );
    7676
    7777                // Make some posts
    78                 self::$factory->post->create_many( 5 );
     78                self::factory()->post->create_many( 5 );
    7979        }
    8080
    8181        /**
    abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { 
    148148         */
    149149        protected function _setRole( $role ) {
    150150                $post = $_POST;
    151                 $user_id = self::$factory->user->create( array( 'role' => $role ) );
     151                $user_id = self::factory()->user->create( array( 'role' => $role ) );
    152152                wp_set_current_user( $user_id );
    153153                $_POST = array_merge($_POST, $post);
    154154        }
  • tests/phpunit/includes/testcase-canonical.php

    diff --git tests/phpunit/includes/testcase-canonical.php tests/phpunit/includes/testcase-canonical.php
    index 6470a64..a82c8c5 100644
    class WP_Canonical_UnitTestCase extends WP_UnitTestCase { 
    4949                wp_set_current_user( self::$author_id );
    5050
    5151                // Already created by install defaults:
    52                 // self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) );
     52                // self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) );
    5353
    5454                self::$post_ids[] = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) );
    5555                self::$post_ids[] = $post_id = $factory->post->create( array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' ) );
  • tests/phpunit/includes/testcase-xmlrpc.php

    diff --git tests/phpunit/includes/testcase-xmlrpc.php tests/phpunit/includes/testcase-xmlrpc.php
    index 6f69569..5fefb51 100644
    class WP_XMLRPC_UnitTestCase extends WP_UnitTestCase { 
    2222        }
    2323
    2424        protected function make_user_by_role( $role ) {
    25                 return self::$factory->user->create( array(
     25                return self::factory()->user->create( array(
    2626                        'user_login' => $role,
    2727                        'user_pass'  => $role,
    2828                        'role'       => $role
  • tests/phpunit/includes/testcase.php

    diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
    index e7c3308..e3cc573 100644
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    1414        protected static $hooks_saved = array();
    1515        protected static $ignore_files;
    1616
    17         /**
    18          * @var WP_UnitTest_Factory
    19          */
    20         protected static $factory;
     17
     18        function __isset( $name ) {
     19                return 'factory' === $name;
     20        }
     21
     22
     23        function __get( $name ) {
     24                if ( 'factory' === $name ) {
     25                        return self::factory();
     26            }
     27        }
     28
     29
     30
     31        protected static function factory() {
     32                static $factory = null;
     33                if ( ! $factory ) {
     34                        $factory = new WP_UnitTest_Factory();
     35                }
     36                return $factory;
     37        }
    2138
    2239        public static function get_called_class() {
    2340                if ( function_exists( 'get_called_class' ) ) {
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    3754        public static function setUpBeforeClass() {
    3855                parent::setUpBeforeClass();
    3956
    40                 if ( ! self::$factory ) {
    41                         self::$factory = new WP_UnitTest_Factory();
    42                 }
    43 
    4457                $c = self::get_called_class();
    4558                if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
    4659                        return;
    4760                }
    4861
    49                 call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$factory );
     62                call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() );
    5063
    5164                self::commit_transaction();
    5265        }
  • tests/phpunit/tests/admin/includesComment.php

    diff --git tests/phpunit/tests/admin/includesComment.php tests/phpunit/tests/admin/includesComment.php
    index 46f3b11..36f9897 100644
     
    66 */
    77class Tests_Admin_IncludesComment extends WP_UnitTestCase {
    88        public function test_must_match_date_and_author() {
    9                 $p1 = self::$factory->post->create();
    10                 $c1 = self::$factory->comment->create( array(
     9                $p1 = self::factory()->post->create();
     10                $c1 = self::factory()->comment->create( array(
    1111                        'comment_author' => 1,
    1212                        'comment_date' => '2014-05-06 12:00:00',
    1313                        'comment_post_ID' => $p1,
    1414                ) );
    1515
    16                 $p2 = self::$factory->post->create();
    17                 $c2 = self::$factory->comment->create( array(
     16                $p2 = self::factory()->post->create();
     17                $c2 = self::factory()->comment->create( array(
    1818                        'comment_author' => 2,
    1919                        'comment_date' => '2004-01-02 12:00:00',
    2020                        'comment_post_ID' => $p2,
    class Tests_Admin_IncludesComment extends WP_UnitTestCase { 
    2828         * @ticket 33871
    2929         */
    3030        public function test_default_value_of_timezone_should_be_blog() {
    31                 $p = self::$factory->post->create();
    32                 $c = self::$factory->comment->create( array(
     31                $p = self::factory()->post->create();
     32                $c = self::factory()->comment->create( array(
    3333                        'comment_author' => 1,
    3434                        'comment_post_ID' => $p,
    3535                        'comment_date' => '2014-05-06 12:00:00',
    class Tests_Admin_IncludesComment extends WP_UnitTestCase { 
    4343         * @ticket 33871
    4444         */
    4545        public function test_should_respect_timezone_blog() {
    46                 $p = self::$factory->post->create();
    47                 $c = self::$factory->comment->create( array(
     46                $p = self::factory()->post->create();
     47                $c = self::factory()->comment->create( array(
    4848                        'comment_author' => 1,
    4949                        'comment_post_ID' => $p,
    5050                        'comment_date' => '2014-05-06 12:00:00',
    class Tests_Admin_IncludesComment extends WP_UnitTestCase { 
    5858         * @ticket 33871
    5959         */
    6060        public function test_should_respect_timezone_gmt() {
    61                 $p = self::$factory->post->create();
    62                 $c = self::$factory->comment->create( array(
     61                $p = self::factory()->post->create();
     62                $c = self::factory()->comment->create( array(
    6363                        'comment_author' => 1,
    6464                        'comment_post_ID' => $p,
    6565                        'comment_date' => '2014-05-06 12:00:00',
    class Tests_Admin_IncludesComment extends WP_UnitTestCase { 
    7373         * @ticket 33871
    7474         */
    7575        public function test_invalid_timezone_should_fall_back_on_blog() {
    76                 $p = self::$factory->post->create();
    77                 $c = self::$factory->comment->create( array(
     76                $p = self::factory()->post->create();
     77                $c = self::factory()->comment->create( array(
    7878                        'comment_author' => 1,
    7979                        'comment_post_ID' => $p,
    8080                        'comment_date' => '2014-05-06 12:00:00',
  • tests/phpunit/tests/admin/includesPlugin.php

    diff --git tests/phpunit/tests/admin/includesPlugin.php tests/phpunit/tests/admin/includesPlugin.php
    index a51a929..b7ed20d 100644
    class Tests_Admin_includesPlugin extends WP_UnitTestCase { 
    2929
    3030        function test_menu_page_url() {
    3131                $current_user = get_current_user_id();
    32                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     32                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    3333                update_option( 'siteurl', 'http://example.com' );
    3434
    3535                // add some pages
  • tests/phpunit/tests/admin/includesPost.php

    diff --git tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/admin/includesPost.php
    index 7fa3dd3..8874a1c 100644
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    1111        }
    1212
    1313        function test__wp_translate_postdata_cap_checks_contributor() {
    14                 $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) );
    15                 $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     14                $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
     15                $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1616
    1717                wp_set_current_user( $contributor_id );
    1818
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    5151
    5252                // Edit Draft Post for another user
    5353                $_post_data = array();
    54                 $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $editor_id ) );
     54                $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $editor_id ) );
    5555                $_post_data['post_author'] = $editor_id;
    5656                $_post_data['post_type'] = 'post';
    5757                $_post_data['post_status'] = 'draft';
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    6464        }
    6565
    6666        function test__wp_translate_postdata_cap_checks_editor() {
    67                 $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) );
    68                 $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     67                $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
     68                $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    6969
    7070                wp_set_current_user( $editor_id );
    7171
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    104104
    105105                // Edit Draft Post for another user
    106106                $_post_data = array();
    107                 $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $contributor_id ) );
     107                $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $contributor_id ) );
    108108                $_post_data['post_author'] = $contributor_id;
    109109                $_post_data['post_type'] = 'post';
    110110                $_post_data['post_status'] = 'draft';
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    122122         * @ticket 25272
    123123         */
    124124        function test_edit_post_auto_draft() {
    125                 $user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     125                $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    126126                wp_set_current_user( $user_id );
    127                 $post = self::$factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
     127                $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
    128128                $this->assertEquals( 'auto-draft', $post->post_status );
    129129                $post_data = array(
    130130                        'post_title' => 'Post title',
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    140140         * @ticket 30615
    141141         */
    142142        public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() {
    143                 $u = self::$factory->user->create( array( 'role' => 'editor' ) );
     143                $u = self::factory()->user->create( array( 'role' => 'editor' ) );
    144144                wp_set_current_user( $u );
    145145
    146146                register_taxonomy( 'wptests_tax', array( 'post' ) );
    147                 $t1 = self::$factory->term->create( array(
     147                $t1 = self::factory()->term->create( array(
    148148                        'taxonomy' => 'wptests_tax',
    149149                        'name' => 'foo',
    150150                        'slug' => 'bar',
    151151                ) );
    152                 $t2 = self::$factory->term->create( array(
     152                $t2 = self::factory()->term->create( array(
    153153                        'taxonomy' => 'wptests_tax',
    154154                        'name' => 'bar',
    155155                        'slug' => 'foo',
    156156                ) );
    157157
    158                 $p = self::$factory->post->create();
     158                $p = self::factory()->post->create();
    159159
    160160                $post_data = array(
    161161                        'post_ID' => $p,
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    179179         * @ticket 30615
    180180         */
    181181        public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() {
    182                 $u = self::$factory->user->create( array( 'role' => 'editor' ) );
     182                $u = self::factory()->user->create( array( 'role' => 'editor' ) );
    183183                wp_set_current_user( $u );
    184184
    185185                register_taxonomy( 'wptests_tax', array( 'post' ) );
    186                 $t1 = self::$factory->term->create( array(
     186                $t1 = self::factory()->term->create( array(
    187187                        'taxonomy' => 'wptests_tax',
    188188                        'name' => 'foo',
    189189                        'slug' => 'bar',
    190190                ) );
    191191
    192                 $p = self::$factory->post->create();
     192                $p = self::factory()->post->create();
    193193
    194194                $post_data = array(
    195195                        'post_ID' => $p,
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    209209         * @ticket 27792
    210210         */
    211211        function test_bulk_edit_posts_stomping() {
    212                 $admin = self::$factory->user->create( array( 'role' => 'administrator' ) );
    213                 $users = self::$factory->user->create_many( 2, array( 'role' => 'author' ) );
     212                $admin = self::factory()->user->create( array( 'role' => 'administrator' ) );
     213                $users = self::factory()->user->create_many( 2, array( 'role' => 'author' ) );
    214214                wp_set_current_user( $admin );
    215215
    216                 $post1 = self::$factory->post->create( array(
     216                $post1 = self::factory()->post->create( array(
    217217                        'post_author'    => $users[0],
    218218                        'comment_status' => 'open',
    219219                        'ping_status'    => 'open',
    220220                        'post_status'    => 'publish',
    221221                ) );
    222222
    223                 $post2 = self::$factory->post->create( array(
     223                $post2 = self::factory()->post->create( array(
    224224                        'post_author'    => $users[1],
    225225                        'comment_status' => 'closed',
    226226                        'ping_status'    => 'closed',
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    255255                $this->set_permalink_structure( "/$permalink_structure/" );
    256256
    257257                $future_date = date( 'Y-m-d H:i:s', time() + 100 );
    258                 $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
     258                $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
    259259
    260260                $found = get_sample_permalink( $p );
    261261                $expected = trailingslashit( home_url( $permalink_structure ) );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    268268         * @ticket 18306
    269269         */
    270270        public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() {
    271                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     271                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    272272
    273273                $future_date = date( 'Y-m-d H:i:s', time() + 100 );
    274                 $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
     274                $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
    275275
    276276                $found = get_sample_permalink_html( $p );
    277277                $this->assertContains( 'href="' . get_option( 'home' ) . '/?p=' . $p . '"', $found );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    284284        public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() {
    285285                $this->set_permalink_structure( '/%postname%/' );
    286286
    287                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     287                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    288288
    289289                $future_date = date( 'Y-m-d H:i:s', time() + 100 );
    290                 $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
     290                $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
    291291
    292292                $found = get_sample_permalink_html( $p );
    293293                $post = get_post( $p );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    301301        public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() {
    302302                $this->set_permalink_structure( '/%postname%/' );
    303303
    304                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     304                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    305305
    306306                // Published posts should use published permalink
    307                 $p = self::$factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );
     307                $p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );
    308308
    309309                $found = get_sample_permalink_html( $p, null, 'new_slug' );
    310310                $post = get_post( $p );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    313313
    314314                // Scheduled posts should use published permalink
    315315                $future_date = date( 'Y-m-d H:i:s', time() + 100 );
    316                 $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) );
     316                $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) );
    317317
    318318                $found = get_sample_permalink_html( $p, null, 'new_slug' );
    319319                $post = get_post( $p );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    321321                $this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message );
    322322
    323323                // Draft posts should use preview link
    324                 $p = self::$factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) );
     324                $p = self::factory()->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) );
    325325
    326326                $found = get_sample_permalink_html( $p, null, 'new_slug' );
    327327                $post = get_post( $p );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    339339        public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() {
    340340                $this->set_permalink_structure( '/%postname%/' );
    341341
    342                 $p = self::$factory->post->create( array(
     342                $p = self::factory()->post->create( array(
    343343                        'post_name' => '2015',
    344344                ) );
    345345
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    353353        public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
    354354                $this->set_permalink_structure( '/%year%/%postname%/' );
    355355
    356                 $p = self::$factory->post->create( array(
     356                $p = self::factory()->post->create( array(
    357357                        'post_name' => '2015',
    358358                ) );
    359359
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    367367        public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() {
    368368                $this->set_permalink_structure( '/%year%/%postname%/' );
    369369
    370                 $p = self::$factory->post->create( array(
     370                $p = self::factory()->post->create( array(
    371371                        'post_name' => '11',
    372372                ) );
    373373
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    381381        public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() {
    382382                $this->set_permalink_structure( '/%year%/%postname%/' );
    383383
    384                 $p = self::$factory->post->create( array(
     384                $p = self::factory()->post->create( array(
    385385                        'post_name' => '13',
    386386                ) );
    387387
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    395395        public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() {
    396396                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    397397
    398                 $p = self::$factory->post->create( array(
     398                $p = self::factory()->post->create( array(
    399399                        'post_name' => '30',
    400400                ) );
    401401
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    409409        public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() {
    410410                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    411411
    412                 self::$factory->post->create( array(
     412                self::factory()->post->create( array(
    413413                        'post_name' => '30-2',
    414414                ) );
    415415
    416                 $p = self::$factory->post->create( array(
     416                $p = self::factory()->post->create( array(
    417417                        'post_name' => '30',
    418418                ) );
    419419
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    427427        public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() {
    428428                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    429429
    430                 $p = self::$factory->post->create( array(
     430                $p = self::factory()->post->create( array(
    431431                        'post_name' => '32',
    432432                ) );
    433433
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    441441        public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
    442442                $this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' );
    443443
    444                 $p = self::$factory->post->create( array(
     444                $p = self::factory()->post->create( array(
    445445                        'post_name' => '30',
    446446                ) );
    447447
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    450450        }
    451451
    452452        public function test_post_exists_should_match_title() {
    453                 $p = self::$factory->post->create( array(
     453                $p = self::factory()->post->create( array(
    454454                        'post_title' => 'Foo Bar',
    455455                ) );
    456456
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    458458        }
    459459
    460460        public function test_post_exists_should_not_match_nonexistent_title() {
    461                 $p = self::$factory->post->create( array(
     461                $p = self::factory()->post->create( array(
    462462                        'post_title' => 'Foo Bar',
    463463                ) );
    464464
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    468468        public function test_post_exists_should_match_nonempty_content() {
    469469                $title = 'Foo Bar';
    470470                $content = 'Foo Bar Baz';
    471                 $p = self::$factory->post->create( array(
     471                $p = self::factory()->post->create( array(
    472472                        'post_title' => $title,
    473473                        'post_content' => $content,
    474474                ) );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    479479        public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() {
    480480                $title = 'Foo Bar';
    481481                $content = 'Foo Bar Baz';
    482                 $p = self::$factory->post->create( array(
     482                $p = self::factory()->post->create( array(
    483483                        'post_title' => $title,
    484484                        'post_content' => $content . ' Quz',
    485485                ) );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    490490        public function test_post_exists_should_match_nonempty_date() {
    491491                $title = 'Foo Bar';
    492492                $date = '2014-05-08 12:00:00';
    493                 $p = self::$factory->post->create( array(
     493                $p = self::factory()->post->create( array(
    494494                        'post_title' => $title,
    495495                        'post_date' => $date,
    496496                ) );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    501501        public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() {
    502502                $title = 'Foo Bar';
    503503                $date = '2014-05-08 12:00:00';
    504                 $p = self::$factory->post->create( array(
     504                $p = self::factory()->post->create( array(
    505505                        'post_title' => $title,
    506506                        'post_date' => '2015-10-10 00:00:00',
    507507                ) );
    class Tests_Admin_includesPost extends WP_UnitTestCase { 
    513513                $title = 'Foo Bar';
    514514                $content = 'Foo Bar Baz';
    515515                $date = '2014-05-08 12:00:00';
    516                 $p = self::$factory->post->create( array(
     516                $p = self::factory()->post->create( array(
    517517                        'post_title' => $title,
    518518                        'post_content' => $content,
    519519                        'post_date' => $date,
  • tests/phpunit/tests/adminbar.php

    diff --git tests/phpunit/tests/adminbar.php tests/phpunit/tests/adminbar.php
    index 0ef6647..cf83adc 100644
    class Tests_AdminBar extends WP_UnitTestCase { 
    1515         * @ticket 21117
    1616         */
    1717        function test_content_post_type() {
    18                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
     18                wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    1919
    2020                register_post_type( 'content', array( 'show_in_admin_bar' => true ) );
    2121
    class Tests_AdminBar extends WP_UnitTestCase { 
    3434         * @ticket 21117
    3535         */
    3636        function test_merging_existing_meta_values() {
    37                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) );
     37                wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    3838
    3939                $admin_bar = new WP_Admin_Bar;
    4040
    class Tests_AdminBar extends WP_UnitTestCase { 
    6262                        $this->markTestSkipped( 'Test does not run in multisite' );
    6363                }
    6464
    65                 $nobody = self::$factory->user->create( array( 'role' => '' ) );
     65                $nobody = self::factory()->user->create( array( 'role' => '' ) );
    6666                $this->assertFalse( user_can( $nobody, 'read' ) );
    6767
    6868                wp_set_current_user( $nobody );
    class Tests_AdminBar extends WP_UnitTestCase { 
    9292                        $this->markTestSkipped( 'Test does not run in multisite' );
    9393                }
    9494
    95                 $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     95                $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    9696                $this->assertTrue( user_can( $editor, 'read' ) );
    9797
    9898                wp_set_current_user( $editor );
    class Tests_AdminBar extends WP_UnitTestCase { 
    125125                        $this->markTestSkipped( 'Test only runs in multisite' );
    126126                }
    127127
    128                 $admin  = self::$factory->user->create( array( 'role' => 'administrator' ) );
    129                 $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     128                $admin  = self::factory()->user->create( array( 'role' => 'administrator' ) );
     129                $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    130130
    131131                $this->assertTrue( user_can( $admin, 'read' ) );
    132132                $this->assertTrue( user_can( $editor, 'read' ) );
    133133
    134                 $new_blog_id = self::$factory->blog->create( array(
     134                $new_blog_id = self::factory()->blog->create( array(
    135135                        'user_id' => $admin,
    136136                ) );
    137137
    class Tests_AdminBar extends WP_UnitTestCase { 
    179179                        $this->markTestSkipped( 'Test only runs in multisite' );
    180180                }
    181181
    182                 $admin  = self::$factory->user->create( array( 'role' => 'administrator' ) );
    183                 $nobody = self::$factory->user->create( array( 'role' => '' ) );
     182                $admin  = self::factory()->user->create( array( 'role' => 'administrator' ) );
     183                $nobody = self::factory()->user->create( array( 'role' => '' ) );
    184184
    185185                $this->assertTrue( user_can( $admin, 'read' ) );
    186186                $this->assertFalse( user_can( $nobody, 'read' ) );
    187187
    188                 $new_blog_id = self::$factory->blog->create( array(
     188                $new_blog_id = self::factory()->blog->create( array(
    189189                        'user_id' => $admin,
    190190                ) );
    191191
  • tests/phpunit/tests/ajax/Autosave.php

    diff --git tests/phpunit/tests/ajax/Autosave.php tests/phpunit/tests/ajax/Autosave.php
    index aac9274..4b2b26c 100644
    class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { 
    3333        public function setUp() {
    3434                parent::setUp();
    3535                // Set a user so the $post has 'post_author'
    36                 $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     36                $this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    3737                wp_set_current_user( $this->user_id );
    3838
    39                 $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
     39                $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    4040                $this->_post = get_post( $post_id );
    4141        }
    4242
    class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { 
    9797         */
    9898        public function test_autosave_locked_post() {
    9999                // Lock the post to another user
    100                 $another_user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     100                $another_user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    101101                wp_set_current_user( $another_user_id );
    102102                wp_set_post_lock( $this->_post->ID );
    103103
  • tests/phpunit/tests/ajax/CustomizeMenus.php

    diff --git tests/phpunit/tests/ajax/CustomizeMenus.php tests/phpunit/tests/ajax/CustomizeMenus.php
    index 94fc646..87191c6 100644
    class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 
    2222        public function setUp() {
    2323                parent::setUp();
    2424                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    25                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     25                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2626                global $wp_customize;
    2727                $this->wp_customize = new WP_Customize_Manager();
    2828                $wp_customize = $this->wp_customize;
    class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 
    6565                        $this->setExpectedException( 'WPAjaxDieStopException' );
    6666                }
    6767
    68                 wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) );
     68                wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );
    6969
    7070                $_POST = array(
    7171                        'action'                => 'load-available-menu-items-customizer',
    class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 
    307307                );
    308308
    309309                // Create some terms and pages.
    310                 self::$factory->term->create_many( 5 );
    311                 self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) );
     310                self::factory()->term->create_many( 5 );
     311                self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) );
    312312
    313313                $_POST = array_merge( array(
    314314                        'action'                => 'load-available-menu-items-customizer',
    class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 
    396396                        $this->setExpectedException( 'WPAjaxDieStopException' );
    397397                }
    398398
    399                 wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) );
     399                wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) );
    400400
    401401                $_POST = array(
    402402                        'action'                => 'search-available-menu-items-customizer',
    class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 
    469469         */
    470470        function test_ajax_search_available_items_results( $post_args, $expected_results ) {
    471471
    472                 self::$factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
     472                self::factory()->post->create_many( 5, array( 'post_title' => 'Test Post' ) );
    473473
    474474                $_POST = array_merge( array(
    475475                        'action'                => 'search-available-menu-items-customizer',
  • tests/phpunit/tests/ajax/DeleteComment.php

    diff --git tests/phpunit/tests/ajax/DeleteComment.php tests/phpunit/tests/ajax/DeleteComment.php
    index 8b3282a..182894e 100644
    class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { 
    2626         */
    2727        public function setUp() {
    2828                parent::setUp();
    29                 $post_id = self::$factory->post->create();
    30                 $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 );
     29                $post_id = self::factory()->post->create();
     30                $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 );
    3131                $this->_comments = array_map( 'get_comment', $this->_comments );
    3232        }
    3333
  • tests/phpunit/tests/ajax/DimComment.php

    diff --git tests/phpunit/tests/ajax/DimComment.php tests/phpunit/tests/ajax/DimComment.php
    index 9795f7b..ba06f42 100644
    class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { 
    2626         */
    2727        public function setUp() {
    2828                parent::setUp();
    29                 $post_id = self::$factory->post->create();
    30                 $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 );
     29                $post_id = self::factory()->post->create();
     30                $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 );
    3131                $this->_comments = array_map( 'get_comment', $this->_comments );
    3232        }
    3333
  • tests/phpunit/tests/ajax/EditComment.php

    diff --git tests/phpunit/tests/ajax/EditComment.php tests/phpunit/tests/ajax/EditComment.php
    index b29690d..ef5c647 100644
    class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { 
    2626         */
    2727        public function setUp() {
    2828                parent::setUp();
    29                 $post_id = self::$factory->post->create();
    30                 self::$factory->comment->create_post_comments( $post_id, 5 );
     29                $post_id = self::factory()->post->create();
     30                self::factory()->comment->create_post_comments( $post_id, 5 );
    3131                $this->_comment_post = get_post( $post_id );
    3232        }
    3333
  • tests/phpunit/tests/ajax/GetComments.php

    diff --git tests/phpunit/tests/ajax/GetComments.php tests/phpunit/tests/ajax/GetComments.php
    index 3702b0b..911bf00 100644
    class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { 
    3232         */
    3333        public function setUp() {
    3434                parent::setUp();
    35                 $post_id = self::$factory->post->create();
    36                 self::$factory->comment->create_post_comments( $post_id, 5 );
     35                $post_id = self::factory()->post->create();
     36                self::factory()->comment->create_post_comments( $post_id, 5 );
    3737                $this->_comment_post = get_post( $post_id );
    3838
    39                 $post_id = self::$factory->post->create();
     39                $post_id = self::factory()->post->create();
    4040                $this->_no_comment_post = get_post( $post_id );
    4141
    4242                unset( $GLOBALS['post_id'] );
  • tests/phpunit/tests/ajax/QuickEdit.php

    diff --git tests/phpunit/tests/ajax/QuickEdit.php tests/phpunit/tests/ajax/QuickEdit.php
    index a7ce874..357ab1f 100644
    class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase { 
    2525                        'hierarchical' => true,
    2626                ) );
    2727
    28                 $t1 = self::$factory->term->create( array(
     28                $t1 = self::factory()->term->create( array(
    2929                        'taxonomy' => 'wptests_tax_1',
    3030                ) );
    31                 $t2 = self::$factory->term->create( array(
     31                $t2 = self::factory()->term->create( array(
    3232                        'taxonomy' => 'wptests_tax_2',
    3333                ) );
    3434
    3535                // Become an administrator.
    3636                $this->_setRole( 'administrator' );
    3737
    38                 $post = self::$factory->post->create_and_get( array(
     38                $post = self::factory()->post->create_and_get( array(
    3939                        'post_author' => get_current_user_id(),
    4040                ) );
    4141
  • tests/phpunit/tests/ajax/ReplytoComment.php

    diff --git tests/phpunit/tests/ajax/ReplytoComment.php tests/phpunit/tests/ajax/ReplytoComment.php
    index 98e7965..e0f001c 100644
    class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { 
    3232         */
    3333        public function setUp() {
    3434                parent::setUp();
    35                 $post_id = self::$factory->post->create();
    36                 self::$factory->comment->create_post_comments( $post_id, 5 );
     35                $post_id = self::factory()->post->create();
     36                self::factory()->comment->create_post_comments( $post_id, 5 );
    3737                $this->_comment_post = get_post( $post_id );
    3838
    39                 $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
     39                $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    4040                $this->_draft_post = get_post( $post_id );
    4141        }
    4242
  • tests/phpunit/tests/attachment/slashes.php

    diff --git tests/phpunit/tests/attachment/slashes.php tests/phpunit/tests/attachment/slashes.php
    index b44d5a9..724e6a9 100644
     
    88class Tests_Attachment_Slashes extends WP_UnitTestCase {
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     11                $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1212                $this->old_current_user = get_current_user_id();
    1313                wp_set_current_user( $this->author_id );
    1414
  • tests/phpunit/tests/avatar.php

    diff --git tests/phpunit/tests/avatar.php tests/phpunit/tests/avatar.php
    index 7475e45..e777f10 100644
    class Tests_Avatar extends WP_UnitTestCase { 
    8787                $url2 = get_avatar_url( $user );
    8888                $this->assertEquals( $url, $url2 );
    8989
    90                 $post_id = self::$factory->post->create( array( 'post_author' => 1 ) );
     90                $post_id = self::factory()->post->create( array( 'post_author' => 1 ) );
    9191                $post = get_post( $post_id );
    9292                $url2 = get_avatar_url( $post );
    9393                $this->assertEquals( $url, $url2 );
    9494
    95                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) );
     95                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) );
    9696                $comment = get_comment( $comment_id );
    9797                $url2 = get_avatar_url( $comment );
    9898                $this->assertEquals( $url, $url2 );
    class Tests_Avatar extends WP_UnitTestCase { 
    138138        public function test_get_avatar_comment_types_filter() {
    139139                $url = get_avatar_url( 1 );
    140140
    141                 $post_id = self::$factory->post->create( array( 'post_author' => 1 ) );
    142                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) );
     141                $post_id = self::factory()->post->create( array( 'post_author' => 1 ) );
     142                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) );
    143143                $comment = get_comment( $comment_id );
    144144
    145145                $url2 = get_avatar_url( $comment );
  • tests/phpunit/tests/canonical/pageOnFront.php

    diff --git tests/phpunit/tests/canonical/pageOnFront.php tests/phpunit/tests/canonical/pageOnFront.php
    index 53afc8c..030befa 100644
    class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase { 
    1818                parent::setUp();
    1919
    2020                update_option( 'show_on_front', 'page' );
    21                 update_option( 'page_for_posts', self::$factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
    22                 update_option( 'page_on_front', self::$factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
     21                update_option( 'page_for_posts', self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
     22                update_option( 'page_on_front', self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
    2323        }
    2424
    2525        /**
  • tests/phpunit/tests/canonical/paged.php

    diff --git tests/phpunit/tests/canonical/paged.php tests/phpunit/tests/canonical/paged.php
    index f734f40..8f1dbfd 100644
    class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { 
    1212                        This is a paragraph.';
    1313                $next = '<!--nextpage-->';
    1414
    15                 $post_id = self::$factory->post->create( array(
     15                $post_id = self::factory()->post->create( array(
    1616                        'post_status' => 'publish',
    1717                        'post_content' => "{$para}{$next}{$para}{$next}{$para}"
    1818                ) );
  • tests/phpunit/tests/category.php

    diff --git tests/phpunit/tests/category.php tests/phpunit/tests/category.php
    index 613e6d5..913f4dc 100644
    class Tests_Category extends WP_UnitTestCase { 
    2121         */
    2222        function test_get_all_category_ids() {
    2323                // create categories
    24                 self::$factory->category->create_many( 2 );
     24                self::factory()->category->create_many( 2 );
    2525
    2626                // create new taxonomy to ensure not included
    2727                register_taxonomy( 'test_tax_cat', 'post' );
    class Tests_Category extends WP_UnitTestCase { 
    3838        function test_get_category_by_slug() {
    3939
    4040                // create Test Categories
    41                 $testcat = self::$factory->category->create_and_get(
     41                $testcat = self::factory()->category->create_and_get(
    4242                        array(
    4343                                'slug' => 'testcat',
    4444                                'name' => 'Test Category 1'
    4545                        )
    4646                );
    47                 $testcat2 = self::$factory->category->create_and_get(
     47                $testcat2 = self::factory()->category->create_and_get(
    4848                        array(
    4949                                'slug' => 'testcat2',
    5050                                'name' => 'Test Category 2'
    class Tests_Category extends WP_UnitTestCase { 
    7373                        'name' => 'Test MCC',
    7474                        'description' => 'Category Test'
    7575                );
    76                 $testcat = self::$factory->category->create_and_get( $testcat_array );
     76                $testcat = self::factory()->category->create_and_get( $testcat_array );
    7777                $testcat_array['term_id'] = $testcat->term_id;
    7878
    7979                $testcat2_array = array(
    class Tests_Category extends WP_UnitTestCase { 
    8282                        'description' => 'Category Test',
    8383                        'parent' => $testcat->term_id
    8484                );
    85                 $testcat2 = self::$factory->category->create_and_get( $testcat2_array );
     85                $testcat2 = self::factory()->category->create_and_get( $testcat2_array );
    8686                $testcat2_array['term_id'] = $testcat2->term_id;
    8787
    8888                // unset properties to enable validation of object
    class Tests_Category extends WP_UnitTestCase { 
    145145        function test_get_cat_name() {
    146146
    147147                // create Test Category
    148                 $testcat = self::$factory->category->create_and_get(
     148                $testcat = self::factory()->category->create_and_get(
    149149                        array(
    150150                                'slug' => 'testcat',
    151151                                'name' => 'Test Category 1'
    class Tests_Category extends WP_UnitTestCase { 
    165165        function test_get_cat_ID() {
    166166
    167167                // create Test Category
    168                 $testcat = self::$factory->category->create_and_get(
     168                $testcat = self::factory()->category->create_and_get(
    169169                        array(
    170170                                'slug' => 'testcat',
    171171                                'name' => 'Test Category 1'
    class Tests_Category extends WP_UnitTestCase { 
    185185        function test_get_category_by_path() {
    186186
    187187                // create Test Categories
    188                 $root_id = self::$factory->category->create(
     188                $root_id = self::factory()->category->create(
    189189                        array(
    190190                                'slug' => 'root',
    191191                        )
    192192                );
    193                 $root_cat_id = self::$factory->category->create(
     193                $root_cat_id = self::factory()->category->create(
    194194                        array(
    195195                                'slug' => 'cat',
    196196                                'parent' => $root_id
    197197                        )
    198198                );
    199                 $root_cat_cat_id = self::$factory->category->create(
     199                $root_cat_cat_id = self::factory()->category->create(
    200200                        array(
    201201                                'slug' => 'cat', //note this is modified on create
    202202                                'parent' => $root_cat_id
    203203                        )
    204204                );
    205                 $root_path_id = self::$factory->category->create(
     205                $root_path_id = self::factory()->category->create(
    206206                        array(
    207207                                'slug' => 'path',
    208208                                'parent' => $root_id
    209209                        )
    210210                );
    211                 $root_path_cat_id = self::$factory->category->create(
     211                $root_path_cat_id = self::factory()->category->create(
    212212                        array(
    213213                                'slug' => 'cat', //note this is modified on create
    214214                                'parent' => $root_path_id
    215215                        )
    216216                );
    217                 $root_level_id = self::$factory->category->create(
     217                $root_level_id = self::factory()->category->create(
    218218                        array(
    219219                                'slug' => 'level-1',
    220220                                'parent' => $root_id
    221221                        )
    222222                );
    223                 $root_level_cat_id = self::$factory->category->create(
     223                $root_level_cat_id = self::factory()->category->create(
    224224                        array(
    225225                                'slug' => 'cat', //note this is modified on create
    226226                                'parent' => $root_level_id
    class Tests_Category extends WP_UnitTestCase { 
    248248         */
    249249        public function test_wp_dropdown_categories_value_field_should_default_to_term_id() {
    250250                // Create a test category.
    251                 $cat_id = self::$factory->category->create( array(
     251                $cat_id = self::factory()->category->create( array(
    252252                        'name' => 'Test Category',
    253253                        'slug' => 'test_category',
    254254                ) );
    class Tests_Category extends WP_UnitTestCase { 
    268268         */
    269269        public function test_wp_dropdown_categories_value_field_term_id() {
    270270                // Create a test category.
    271                 $cat_id = self::$factory->category->create( array(
     271                $cat_id = self::factory()->category->create( array(
    272272                        'name' => 'Test Category',
    273273                        'slug' => 'test_category',
    274274                ) );
    class Tests_Category extends WP_UnitTestCase { 
    289289         */
    290290        public function test_wp_dropdown_categories_value_field_slug() {
    291291                // Create a test category.
    292                 $cat_id = self::$factory->category->create( array(
     292                $cat_id = self::factory()->category->create( array(
    293293                        'name' => 'Test Category',
    294294                        'slug' => 'test_category',
    295295                ) );
    class Tests_Category extends WP_UnitTestCase { 
    310310         */
    311311        public function test_wp_dropdown_categories_value_field_should_fall_back_on_term_id_when_an_invalid_value_is_provided() {
    312312                // Create a test category.
    313                 $cat_id = self::$factory->category->create( array(
     313                $cat_id = self::factory()->category->create( array(
    314314                        'name' => 'Test Category',
    315315                        'slug' => 'test_category',
    316316                ) );
    class Tests_Category extends WP_UnitTestCase { 
    330330         * @ticket 32330
    331331         */
    332332        public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() {
    333                 $c1 = self::$factory->category->create( array(
     333                $c1 = self::factory()->category->create( array(
    334334                        'name' => 'Test Category 1',
    335335                        'slug' => 'test_category_1',
    336336                ) );
    337337
    338                 $c2 = self::$factory->category->create( array(
     338                $c2 = self::factory()->category->create( array(
    339339                        'name' => 'Test Category 2',
    340340                        'slug' => 'test_category_2',
    341341                ) );
    class Tests_Category extends WP_UnitTestCase { 
    354354         * @ticket 33452
    355355         */
    356356        public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_no_selected_value_is_explicitly_passed_and_value_field_does_not_have_string_values() {
    357                 $cats = self::$factory->category->create_many( 3 );
     357                $cats = self::factory()->category->create_many( 3 );
    358358
    359359                $found = wp_dropdown_categories( array(
    360360                        'echo' => 0,
    class Tests_Category extends WP_UnitTestCase { 
    375375         * @ticket 33452
    376376         */
    377377        public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_selected_value_of_0_string_is_explicitly_passed_and_value_field_does_not_have_string_values() {
    378                 $cats = self::$factory->category->create_many( 3 );
     378                $cats = self::factory()->category->create_many( 3 );
    379379
    380380                $found = wp_dropdown_categories( array(
    381381                        'echo' => 0,
  • tests/phpunit/tests/category/getCategoryParents.php

    diff --git tests/phpunit/tests/category/getCategoryParents.php tests/phpunit/tests/category/getCategoryParents.php
    index b9c6998..9805de9 100644
    class Tests_Category_GetCategoryParents extends WP_UnitTestCase { 
    1010        public function setUp() {
    1111                parent::setUp();
    1212
    13                 $this->c1 = self::$factory->category->create_and_get();
    14                 $this->c2 = self::$factory->category->create_and_get( array(
     13                $this->c1 = self::factory()->category->create_and_get();
     14                $this->c2 = self::factory()->category->create_and_get( array(
    1515                        'parent' => $this->c1->term_id,
    1616                ) );
    1717        }
    class Tests_Category_GetCategoryParents extends WP_UnitTestCase { 
    5151        }
    5252
    5353        public function test_visited() {
    54                 $c3 = self::$factory->category->create_and_get( array(
     54                $c3 = self::factory()->category->create_and_get( array(
    5555                        'parent' => $this->c2->term_id,
    5656                ) );
    57                 $c4 = self::$factory->category->create_and_get( array(
     57                $c4 = self::factory()->category->create_and_get( array(
    5858                        'parent' => $c3->term_id,
    5959                ) );
    6060
  • tests/phpunit/tests/category/wpListCategories.php

    diff --git tests/phpunit/tests/category/wpListCategories.php tests/phpunit/tests/category/wpListCategories.php
    index 0a49f0f..048f72d 100644
     
    55 */
    66class Tests_Category_WpListCategories extends WP_UnitTestCase {
    77        public function test_class() {
    8                 $c = self::$factory->category->create();
     8                $c = self::factory()->category->create();
    99
    1010                $found = wp_list_categories( array(
    1111                        'hide_empty' => false,
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    1616        }
    1717
    1818        public function test_class_containing_current_cat() {
    19                 $c1 = self::$factory->category->create();
    20                 $c2 = self::$factory->category->create();
     19                $c1 = self::factory()->category->create();
     20                $c2 = self::factory()->category->create();
    2121
    2222                $found = wp_list_categories( array(
    2323                        'hide_empty' => false,
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    3030        }
    3131
    3232        public function test_class_containing_current_cat_parent() {
    33                 $c1 = self::$factory->category->create();
    34                 $c2 = self::$factory->category->create( array(
     33                $c1 = self::factory()->category->create();
     34                $c2 = self::factory()->category->create( array(
    3535                        'parent' => $c1,
    3636                ) );
    3737
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    4949         * @ticket 33565
    5050         */
    5151        public function test_current_category_should_accept_an_array_of_ids() {
    52                 $cats = self::$factory->category->create_many( 3 );
     52                $cats = self::factory()->category->create_many( 3 );
    5353
    5454                $found = wp_list_categories( array(
    5555                        'echo' => false,
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    6666         * @ticket 16792
    6767         */
    6868        public function test_should_not_create_element_when_cat_name_is_filtered_to_empty_string() {
    69                 $c1 = self::$factory->category->create( array(
     69                $c1 = self::factory()->category->create( array(
    7070                        'name' => 'Test Cat 1',
    7171                ) );
    72                 $c2 = self::$factory->category->create( array(
     72                $c2 = self::factory()->category->create( array(
    7373                        'name' => 'Test Cat 2',
    7474                ) );
    7575
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    8888        }
    8989
    9090        public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {
    91                 $cats = self::$factory->category->create_many( 2 );
     91                $cats = self::factory()->category->create_many( 2 );
    9292
    9393                $found = wp_list_categories( array(
    9494                        'echo' => false,
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    101101        }
    102102
    103103        public function test_show_option_all_link_should_respect_page_for_posts() {
    104                 $cats = self::$factory->category->create_many( 2 );
    105                 $p = self::$factory->post->create( array( 'post_type' => 'page' ) );
     104                $cats = self::factory()->category->create_many( 2 );
     105                $p = self::factory()->post->create( array( 'post_type' => 'page' ) );
    106106
    107107                update_option( 'show_on_front', 'page' );
    108108                update_option( 'page_for_posts', $p );
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    125125                register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
    126126                register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
    127127
    128                 $terms = self::$factory->term->create_many( 2, array(
     128                $terms = self::factory()->term->create_many( 2, array(
    129129                        'taxonomy' => 'wptests_tax',
    130130                ) );
    131131
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    149149                register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
    150150                register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
    151151
    152                 $terms = self::$factory->term->create_many( 2, array(
     152                $terms = self::factory()->term->create_many( 2, array(
    153153                        'taxonomy' => 'wptests_tax',
    154154                ) );
    155155
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    170170                register_post_type( 'wptests_pt2', array( 'has_archive' => true ) );
    171171                register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) );
    172172
    173                 $terms = self::$factory->term->create_many( 2, array(
     173                $terms = self::factory()->term->create_many( 2, array(
    174174                        'taxonomy' => 'wptests_tax',
    175175                ) );
    176176
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    191191                register_post_type( 'wptests_pt2', array( 'has_archive' => false ) );
    192192                register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) );
    193193
    194                 $terms = self::$factory->term->create_many( 2, array(
     194                $terms = self::factory()->term->create_many( 2, array(
    195195                        'taxonomy' => 'wptests_tax',
    196196                ) );
    197197
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    254254         * @ticket 33460
    255255         */
    256256        public function test_hide_title_if_empty_should_be_ignored_when_category_list_is_not_empty() {
    257                 $cat = self::$factory->category->create();
     257                $cat = self::factory()->category->create();
    258258
    259259                $found = wp_list_categories( array(
    260260                        'echo' => false,
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    269269         * @ticket 12981
    270270         */
    271271        public function test_exclude_tree_should_be_respected() {
    272                 $c = self::$factory->category->create();
    273                 $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
    274                 $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
     272                $c = self::factory()->category->create();
     273                $parent = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
     274                $child = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
    275275
    276276                $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
    277277
    class Tests_Category_WpListCategories extends WP_UnitTestCase { 
    286286         * @ticket 12981
    287287         */
    288288        public function test_exclude_tree_should_be_merged_with_exclude() {
    289                 $c = self::$factory->category->create();
    290                 $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
    291                 $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
    292                 $parent2 = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) );
    293                 $child2 = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) );
     289                $c = self::factory()->category->create();
     290                $parent = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
     291                $child = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) );
     292                $parent2 = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) );
     293                $child2 = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) );
    294294
    295295                $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent );
    296296
  • tests/phpunit/tests/comment-submission.php

    diff --git tests/phpunit/tests/comment-submission.php tests/phpunit/tests/comment-submission.php
    index 1fed4f4..96ba7a2 100644
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    3838
    3939                $this->assertSame( 0, did_action( $error ) );
    4040
    41                 $post = self::$factory->post->create_and_get( array(
     41                $post = self::factory()->post->create_and_get( array(
    4242                        'comment_status' => 'closed',
    4343                ) );
    4444                $data = array(
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    5858
    5959                $this->assertSame( 0, did_action( $error ) );
    6060
    61                 $post = self::$factory->post->create_and_get();
     61                $post = self::factory()->post->create_and_get();
    6262                wp_trash_post( $post );
    6363                $data = array(
    6464                        'comment_post_ID' => $post->ID,
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    7777
    7878                $this->assertSame( 0, did_action( $error ) );
    7979
    80                 $post = self::$factory->post->create_and_get( array(
     80                $post = self::factory()->post->create_and_get( array(
    8181                        'post_status' => 'draft',
    8282                ) );
    8383                $data = array(
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    9898
    9999                $this->assertSame( 0, did_action( $error ) );
    100100
    101                 $post = self::$factory->post->create_and_get( array(
     101                $post = self::factory()->post->create_and_get( array(
    102102                        'post_date' => date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
    103103                ) );
    104104
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    121121
    122122                $this->assertSame( 0, did_action( $error ) );
    123123
    124                 $post = self::$factory->post->create_and_get( array(
     124                $post = self::factory()->post->create_and_get( array(
    125125                        'post_password' => 'password',
    126126                ) );
    127127                $data = array(
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    142142
    143143                $_COOKIE['wp-postpass_' . COOKIEHASH] = $hasher->HashPassword( $password );
    144144
    145                 $post = self::$factory->post->create_and_get( array(
     145                $post = self::factory()->post->create_and_get( array(
    146146                        'post_password' => $password,
    147147                ) );
    148148                $data = array(
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    162162
    163163        public function test_submitting_valid_comment_as_logged_in_user_succeeds() {
    164164
    165                 $user = self::$factory->user->create_and_get( array(
     165                $user = self::factory()->user->create_and_get( array(
    166166                        'user_url' => 'http://user.example.org'
    167167                ) );
    168168
    169169                wp_set_current_user( $user->ID );
    170170
    171                 $post = self::$factory->post->create_and_get();
     171                $post = self::factory()->post->create_and_get();
    172172                $data = array(
    173173                        'comment_post_ID' => $post->ID,
    174174                        'comment'         => 'Comment',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    187187
    188188        public function test_submitting_valid_comment_anonymously_succeeds() {
    189189
    190                 $post = self::$factory->post->create_and_get();
     190                $post = self::factory()->post->create_and_get();
    191191                $data = array(
    192192                        'comment_post_ID' => $post->ID,
    193193                        'comment'         => 'Comment',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    214214         */
    215215        public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
    216216
    217                 $post = self::$factory->post->create_and_get();
     217                $post = self::factory()->post->create_and_get();
    218218                $data = array(
    219219                        'comment_post_ID' => $post->ID,
    220220                        'comment'         => 'Comment with 1 slash: \\',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    236236
    237237                $error = 'not_logged_in';
    238238
    239                 $post = self::$factory->post->create_and_get( array(
     239                $post = self::factory()->post->create_and_get( array(
    240240                        'post_status' => 'private',
    241241                ) );
    242242                $data = array(
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    252252
    253253        public function test_submitting_comment_to_own_private_post_succeeds() {
    254254
    255                 $user = self::$factory->user->create_and_get();
     255                $user = self::factory()->user->create_and_get();
    256256
    257257                wp_set_current_user( $user->ID );
    258258
    259                 $post = self::$factory->post->create_and_get( array(
     259                $post = self::factory()->post->create_and_get( array(
    260260                        'post_status' => 'private',
    261261                        'post_author' => $user->ID,
    262262                ) );
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    274274
    275275        public function test_submitting_comment_to_accessible_private_post_succeeds() {
    276276
    277                 $author = self::$factory->user->create_and_get( array(
     277                $author = self::factory()->user->create_and_get( array(
    278278                        'role' => 'author',
    279279                ) );
    280                 $user = self::$factory->user->create_and_get( array(
     280                $user = self::factory()->user->create_and_get( array(
    281281                        'role' => 'editor',
    282282                ) );
    283283
    284284                wp_set_current_user( $user->ID );
    285285
    286                 $post = self::$factory->post->create_and_get( array(
     286                $post = self::factory()->post->create_and_get( array(
    287287                        'post_status' => 'private',
    288288                        'post_author' => $author->ID,
    289289                ) );
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    301301
    302302        public function test_anonymous_user_cannot_comment_unfiltered_html() {
    303303
    304                 $post = self::$factory->post->create_and_get();
     304                $post = self::factory()->post->create_and_get();
    305305                $data = array(
    306306                        'comment_post_ID' => $post->ID,
    307307                        'comment'         => 'Comment <script>alert(document.cookie);</script>',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    318318
    319319        public function test_unprivileged_user_cannot_comment_unfiltered_html() {
    320320
    321                 $user = self::$factory->user->create_and_get( array(
     321                $user = self::factory()->user->create_and_get( array(
    322322                        'role' => 'author',
    323323                ) );
    324324                wp_set_current_user( $user->ID );
    325325
    326326                $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    327327
    328                 $post = self::$factory->post->create_and_get();
     328                $post = self::factory()->post->create_and_get();
    329329                $data = array(
    330330                        'comment_post_ID' => $post->ID,
    331331                        'comment'         => 'Comment <script>alert(document.cookie);</script>',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    340340
    341341        public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() {
    342342
    343                 $user = self::$factory->user->create_and_get( array(
     343                $user = self::factory()->user->create_and_get( array(
    344344                        'role' => 'author',
    345345                ) );
    346346                wp_set_current_user( $user->ID );
    347347
    348348                $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    349349
    350                 $post   = self::$factory->post->create_and_get();
     350                $post   = self::factory()->post->create_and_get();
    351351                $action = 'unfiltered-html-comment_' . $post->ID;
    352352                $nonce  = wp_create_nonce( $action );
    353353
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    370370
    371371                $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) );
    372372
    373                 $user = self::$factory->user->create_and_get( array(
     373                $user = self::factory()->user->create_and_get( array(
    374374                        'role' => 'editor',
    375375                ) );
    376376
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    384384
    385385                $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    386386
    387                 $post   = self::$factory->post->create_and_get();
     387                $post   = self::factory()->post->create_and_get();
    388388                $action = 'unfiltered-html-comment_' . $post->ID;
    389389                $nonce  = wp_create_nonce( $action );
    390390
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    405405
    406406        public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() {
    407407
    408                 $user = self::$factory->user->create_and_get( array(
     408                $user = self::factory()->user->create_and_get( array(
    409409                        'role' => 'editor',
    410410                ) );
    411411
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    419419
    420420                $this->assertTrue( current_user_can( 'unfiltered_html' ) );
    421421
    422                 $post   = self::$factory->post->create_and_get();
     422                $post   = self::factory()->post->create_and_get();
    423423                $data = array(
    424424                        'comment_post_ID' => $post->ID,
    425425                        'comment'         => 'Comment <script>alert(document.cookie);</script>',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    439439                $_comment_registration = get_option( 'comment_registration' );
    440440                update_option( 'comment_registration', '1' );
    441441
    442                 $post = self::$factory->post->create_and_get();
     442                $post = self::factory()->post->create_and_get();
    443443                $data = array(
    444444                        'comment_post_ID' => $post->ID,
    445445                );
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    459459                $_require_name_email = get_option( 'require_name_email' );
    460460                update_option( 'require_name_email', '1' );
    461461
    462                 $post = self::$factory->post->create_and_get();
     462                $post = self::factory()->post->create_and_get();
    463463                $data = array(
    464464                        'comment_post_ID' => $post->ID,
    465465                        'comment'         => 'Comment',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    481481                $_require_name_email = get_option( 'require_name_email' );
    482482                update_option( 'require_name_email', '1' );
    483483
    484                 $post = self::$factory->post->create_and_get();
     484                $post = self::factory()->post->create_and_get();
    485485                $data = array(
    486486                        'comment_post_ID' => $post->ID,
    487487                        'comment'         => 'Comment',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    503503                $_require_name_email = get_option( 'require_name_email' );
    504504                update_option( 'require_name_email', '1' );
    505505
    506                 $post = self::$factory->post->create_and_get();
     506                $post = self::factory()->post->create_and_get();
    507507                $data = array(
    508508                        'comment_post_ID' => $post->ID,
    509509                        'comment'         => 'Comment',
    class Tests_Comment_Submission extends WP_UnitTestCase { 
    523523
    524524                $error = 'require_valid_comment';
    525525
    526                 $post = self::$factory->post->create_and_get();
     526                $post = self::factory()->post->create_and_get();
    527527                $data = array(
    528528                        'comment_post_ID' => $post->ID,
    529529                        'comment'         => '',
  • tests/phpunit/tests/comment.php

    diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php
    index a059149..cf55e07 100644
    class Tests_Comment extends WP_UnitTestCase { 
    2121        }
    2222
    2323        function test_wp_update_comment() {
    24                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
    25                 $post2 = self::$factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) );
    26                 $comments = self::$factory->comment->create_post_comments( $post->ID, 5 );
     24                $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
     25                $post2 = self::factory()->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) );
     26                $comments = self::factory()->comment->create_post_comments( $post->ID, 5 );
    2727                $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
    2828                $this->assertEquals( 1, $result );
    2929                $comment = get_comment( $comments[0] );
    class Tests_Comment extends WP_UnitTestCase { 
    3939         * @ticket 30627
    4040         */
    4141        function test_wp_update_comment_updates_comment_type() {
    42                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     42                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
    4343
    4444                wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) );
    4545
    class Tests_Comment extends WP_UnitTestCase { 
    5151         * @ticket 30307
    5252         */
    5353        function test_wp_update_comment_updates_user_id() {
    54                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     54                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
    5555
    5656                wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1 ) );
    5757
    class Tests_Comment extends WP_UnitTestCase { 
    6060        }
    6161
    6262        public function test_get_approved_comments() {
    63                 $ca1 = self::$factory->comment->create( array(
     63                $ca1 = self::factory()->comment->create( array(
    6464                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
    6565                ) );
    66                 $ca2 = self::$factory->comment->create( array(
     66                $ca2 = self::factory()->comment->create( array(
    6767                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
    6868                ) );
    69                 $ca3 = self::$factory->comment->create( array(
     69                $ca3 = self::factory()->comment->create( array(
    7070                        'comment_post_ID' => self::$post_id, 'comment_approved' => '0'
    7171                ) );
    72                 $c2 = self::$factory->comment->create( array(
     72                $c2 = self::factory()->comment->create( array(
    7373                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback'
    7474                ) );
    75                 $c3 = self::$factory->comment->create( array(
     75                $c3 = self::factory()->comment->create( array(
    7676                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback'
    7777                ) );
    78                 $c4 = self::$factory->comment->create( array(
     78                $c4 = self::factory()->comment->create( array(
    7979                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario'
    8080                ) );
    81                 $c5 = self::$factory->comment->create( array(
     81                $c5 = self::factory()->comment->create( array(
    8282                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi'
    8383                ) );
    8484
    class Tests_Comment extends WP_UnitTestCase { 
    9292         * @ticket 30412
    9393         */
    9494        public function test_get_approved_comments_with_post_id_0_should_return_empty_array() {
    95                 $ca1 = self::$factory->comment->create( array(
     95                $ca1 = self::factory()->comment->create( array(
    9696                        'comment_post_ID' => self::$post_id, 'comment_approved' => '1'
    9797                ) );
    9898
    class Tests_Comment extends WP_UnitTestCase { 
    256256         * @ticket 32566
    257257         */
    258258        public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() {
    259                 $p = self::$factory->post->create( array(
     259                $p = self::factory()->post->create( array(
    260260                        'post_author' => 0,
    261261                ) );
    262262
    263                 $c = self::$factory->comment->create( array(
     263                $c = self::factory()->comment->create( array(
    264264                        'comment_post_ID' => $p,
    265265                ) );
    266266
    class Tests_Comment extends WP_UnitTestCase { 
    271271         * @ticket 33587
    272272         */
    273273        public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() {
    274                 $c = self::$factory->comment->create( array(
     274                $c = self::factory()->comment->create( array(
    275275                        'comment_post_ID' => self::$post_id,
    276276                        'comment_approved' => 'spam',
    277277                ) );
    class Tests_Comment extends WP_UnitTestCase { 
    284284         * @ticket 12431
    285285         */
    286286        public function test_wp_new_comment_with_meta() {
    287                 $c = self::$factory->comment->create( array(
     287                $c = self::factory()->comment->create( array(
    288288                        'comment_approved' => '1',
    289289                        'comment_meta' => array(
    290290                                'food' => 'taco',
    class Tests_Comment extends WP_UnitTestCase { 
    299299         * @ticket 8071
    300300         */
    301301        public function test_wp_comment_get_children_should_fill_children() {
    302                 $c1 = self::$factory->comment->create( array(
     302                $c1 = self::factory()->comment->create( array(
    303303                        'comment_post_ID' => self::$post_id,
    304304                        'comment_approved' => '1',
    305305                ) );
    306306
    307                 $c2 = self::$factory->comment->create( array(
     307                $c2 = self::factory()->comment->create( array(
    308308                        'comment_post_ID' => self::$post_id,
    309309                        'comment_approved' => '1',
    310310                        'comment_parent' => $c1,
    311311                ) );
    312312
    313                 $c3 = self::$factory->comment->create( array(
     313                $c3 = self::factory()->comment->create( array(
    314314                        'comment_post_ID' => self::$post_id,
    315315                        'comment_approved' => '1',
    316316                        'comment_parent' => $c2,
    317317                ) );
    318318
    319                 $c4 = self::$factory->comment->create( array(
     319                $c4 = self::factory()->comment->create( array(
    320320                        'comment_post_ID' => self::$post_id,
    321321                        'comment_approved' => '1',
    322322                        'comment_parent' => $c1,
    323323                ) );
    324324
    325                 $c5 = self::$factory->comment->create( array(
     325                $c5 = self::factory()->comment->create( array(
    326326                        'comment_post_ID' => self::$post_id,
    327327                        'comment_approved' => '1',
    328328                ) );
    329329
    330                 $c6 = self::$factory->comment->create( array(
     330                $c6 = self::factory()->comment->create( array(
    331331                        'comment_post_ID' => self::$post_id,
    332332                        'comment_approved' => '1',
    333333                        'comment_parent' => $c5,
    class Tests_Comment extends WP_UnitTestCase { 
    347347         * @group 27571
    348348         */
    349349        public function test_post_properties_should_be_lazyloaded() {
    350                 $c = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     350                $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) );
    351351
    352352                $post = get_post( self::$post_id );
    353353                $comment = get_comment( $c );
  • tests/phpunit/tests/comment/checkComment.php

    diff --git tests/phpunit/tests/comment/checkComment.php tests/phpunit/tests/comment/checkComment.php
    index 40bca3a..576b838 100644
    class Tests_Comment_CheckComment extends WP_UnitTestCase { 
    3131        }
    3232
    3333        public function test_should_return_true_when_comment_whitelist_is_enabled_and_author_has_approved_comment() {
    34                 $post_id = self::$factory->post->create();
     34                $post_id = self::factory()->post->create();
    3535                $prev_args = array(
    3636                        'comment_post_ID'      => $post_id,
    3737                        'comment_content'      => 'Can we build it?',
    class Tests_Comment_CheckComment extends WP_UnitTestCase { 
    3939                        'comment_author_email' => 'bob@example.com',
    4040                        'comment_author'       => 'BobtheBuilder',
    4141                );
    42                 $prev_comment_id = self::$factory->comment->create( $prev_args );
     42                $prev_comment_id = self::factory()->comment->create( $prev_args );
    4343
    4444                update_option( 'comment_whitelist', 1 );
    4545
  • tests/phpunit/tests/comment/commentForm.php

    diff --git tests/phpunit/tests/comment/commentForm.php tests/phpunit/tests/comment/commentForm.php
    index bd91dbf..c6bb43f 100644
     
    55 */
    66class Tests_Comment_CommentForm extends WP_UnitTestCase {
    77        public function test_default_markup_for_submit_button_and_wrapper() {
    8                 $p = self::$factory->post->create();
     8                $p = self::factory()->post->create();
    99
    1010                $args = array(
    1111                        'name_submit' => 'foo-name',
    class Tests_Comment_CommentForm extends WP_UnitTestCase { 
    2121        }
    2222
    2323        public function test_custom_submit_button() {
    24                 $p = self::$factory->post->create();
     24                $p = self::factory()->post->create();
    2525
    2626                $args = array(
    2727                        'name_submit' => 'foo-name',
    class Tests_Comment_CommentForm extends WP_UnitTestCase { 
    3737        }
    3838
    3939        public function test_custom_submit_field() {
    40                 $p = self::$factory->post->create();
     40                $p = self::factory()->post->create();
    4141
    4242                $args = array(
    4343                        'name_submit' => 'foo-name',
    class Tests_Comment_CommentForm extends WP_UnitTestCase { 
    5757         * @ticket 32312
    5858         */
    5959        public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() {
    60                 $p = self::$factory->post->create();
     60                $p = self::factory()->post->create();
    6161
    6262                $args = array(
    6363                        'name_submit' => 'foo-name',
  • tests/phpunit/tests/comment/commentsTemplate.php

    diff --git tests/phpunit/tests/comment/commentsTemplate.php tests/phpunit/tests/comment/commentsTemplate.php
    index 31f7cbf..3e134ad 100644
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    1212         */
    1313        public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest() {
    1414                $now = time();
    15                 $p = self::$factory->post->create();
    16                 $comment_1 = self::$factory->comment->create( array(
     15                $p = self::factory()->post->create();
     16                $comment_1 = self::factory()->comment->create( array(
    1717                        'comment_post_ID' => $p,
    1818                        'comment_content' => '1',
    1919                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    2020                ) );
    21                 $comment_2 = self::$factory->comment->create( array(
     21                $comment_2 = self::factory()->comment->create( array(
    2222                        'comment_post_ID' => $p,
    2323                        'comment_content' => '2',
    2424                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    4242         */
    4343        public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest() {
    4444                $now = time();
    45                 $p = self::$factory->post->create();
    46                 $comment_1 = self::$factory->comment->create( array(
     45                $p = self::factory()->post->create();
     46                $comment_1 = self::factory()->comment->create( array(
    4747                        'comment_post_ID' => $p,
    4848                        'comment_content' => '1',
    4949                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    5050                ) );
    51                 $comment_2 = self::$factory->comment->create( array(
     51                $comment_2 = self::factory()->comment->create( array(
    5252                        'comment_post_ID' => $p,
    5353                        'comment_content' => '2',
    5454                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    7272         */
    7373        public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() {
    7474                $now = time();
    75                 $p = self::$factory->post->create();
    76                 $comment_1 = self::$factory->comment->create( array(
     75                $p = self::factory()->post->create();
     76                $comment_1 = self::factory()->comment->create( array(
    7777                        'comment_post_ID' => $p,
    7878                        'comment_content' => '1',
    7979                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    8080                ) );
    81                 $comment_2 = self::$factory->comment->create( array(
     81                $comment_2 = self::factory()->comment->create( array(
    8282                        'comment_post_ID' => $p,
    8383                        'comment_content' => '2',
    8484                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    102102         */
    103103        public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() {
    104104                $now = time();
    105                 $p = self::$factory->post->create();
    106                 $comment_1 = self::$factory->comment->create( array(
     105                $p = self::factory()->post->create();
     106                $comment_1 = self::factory()->comment->create( array(
    107107                        'comment_post_ID' => $p,
    108108                        'comment_content' => '1',
    109109                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    110110                ) );
    111                 $comment_2 = self::$factory->comment->create( array(
     111                $comment_2 = self::factory()->comment->create( array(
    112112                        'comment_post_ID' => $p,
    113113                        'comment_content' => '2',
    114114                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    132132         */
    133133        public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest_on_subsequent_pages() {
    134134                $now = time();
    135                 $p = self::$factory->post->create();
    136                 $comment_1 = self::$factory->comment->create( array(
     135                $p = self::factory()->post->create();
     136                $comment_1 = self::factory()->comment->create( array(
    137137                        'comment_post_ID' => $p,
    138138                        'comment_content' => '1',
    139139                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    140140                ) );
    141                 $comment_2 = self::$factory->comment->create( array(
     141                $comment_2 = self::factory()->comment->create( array(
    142142                        'comment_post_ID' => $p,
    143143                        'comment_content' => '2',
    144144                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    145145                ) );
    146                 $comment_3 = self::$factory->comment->create( array(
     146                $comment_3 = self::factory()->comment->create( array(
    147147                        'comment_post_ID' => $p,
    148148                        'comment_content' => '3',
    149149                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    150150                ) );
    151                 $comment_4 = self::$factory->comment->create( array(
     151                $comment_4 = self::factory()->comment->create( array(
    152152                        'comment_post_ID' => $p,
    153153                        'comment_content' => '4',
    154154                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    155155                ) );
    156                 $comment_5 = self::$factory->comment->create( array(
     156                $comment_5 = self::factory()->comment->create( array(
    157157                        'comment_post_ID' => $p,
    158158                        'comment_content' => '3',
    159159                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    160160                ) );
    161                 $comment_6 = self::$factory->comment->create( array(
     161                $comment_6 = self::factory()->comment->create( array(
    162162                        'comment_post_ID' => $p,
    163163                        'comment_content' => '4',
    164164                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    187187         */
    188188        public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() {
    189189                $now = time();
    190                 $p = self::$factory->post->create();
    191                 $comment_1 = self::$factory->comment->create( array(
     190                $p = self::factory()->post->create();
     191                $comment_1 = self::factory()->comment->create( array(
    192192                        'comment_post_ID' => $p,
    193193                        'comment_content' => '1',
    194194                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    195195                ) );
    196                 $comment_2 = self::$factory->comment->create( array(
     196                $comment_2 = self::factory()->comment->create( array(
    197197                        'comment_post_ID' => $p,
    198198                        'comment_content' => '2',
    199199                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    200200                ) );
    201                 $comment_3 = self::$factory->comment->create( array(
     201                $comment_3 = self::factory()->comment->create( array(
    202202                        'comment_post_ID' => $p,
    203203                        'comment_content' => '3',
    204204                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    205205                ) );
    206                 $comment_4 = self::$factory->comment->create( array(
     206                $comment_4 = self::factory()->comment->create( array(
    207207                        'comment_post_ID' => $p,
    208208                        'comment_content' => '4',
    209209                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    210210                ) );
    211                 $comment_5 = self::$factory->comment->create( array(
     211                $comment_5 = self::factory()->comment->create( array(
    212212                        'comment_post_ID' => $p,
    213213                        'comment_content' => '3',
    214214                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    215215                ) );
    216                 $comment_6 = self::$factory->comment->create( array(
     216                $comment_6 = self::factory()->comment->create( array(
    217217                        'comment_post_ID' => $p,
    218218                        'comment_content' => '4',
    219219                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    242242         */
    243243        public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() {
    244244                $now = time();
    245                 $p = self::$factory->post->create();
    246                 $comment_1 = self::$factory->comment->create( array(
     245                $p = self::factory()->post->create();
     246                $comment_1 = self::factory()->comment->create( array(
    247247                        'comment_post_ID' => $p,
    248248                        'comment_content' => '1',
    249249                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    250250                ) );
    251                 $comment_2 = self::$factory->comment->create( array(
     251                $comment_2 = self::factory()->comment->create( array(
    252252                        'comment_post_ID' => $p,
    253253                        'comment_content' => '2',
    254254                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    255255                ) );
    256                 $comment_3 = self::$factory->comment->create( array(
     256                $comment_3 = self::factory()->comment->create( array(
    257257                        'comment_post_ID' => $p,
    258258                        'comment_content' => '3',
    259259                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    260260                ) );
    261                 $comment_4 = self::$factory->comment->create( array(
     261                $comment_4 = self::factory()->comment->create( array(
    262262                        'comment_post_ID' => $p,
    263263                        'comment_content' => '4',
    264264                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    287287         */
    288288        public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest_on_subsequent_pages() {
    289289                $now = time();
    290                 $p = self::$factory->post->create();
    291                 $comment_1 = self::$factory->comment->create( array(
     290                $p = self::factory()->post->create();
     291                $comment_1 = self::factory()->comment->create( array(
    292292                        'comment_post_ID' => $p,
    293293                        'comment_content' => '1',
    294294                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    295295                ) );
    296                 $comment_2 = self::$factory->comment->create( array(
     296                $comment_2 = self::factory()->comment->create( array(
    297297                        'comment_post_ID' => $p,
    298298                        'comment_content' => '2',
    299299                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    300300                ) );
    301                 $comment_3 = self::$factory->comment->create( array(
     301                $comment_3 = self::factory()->comment->create( array(
    302302                        'comment_post_ID' => $p,
    303303                        'comment_content' => '3',
    304304                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    305305                ) );
    306                 $comment_4 = self::$factory->comment->create( array(
     306                $comment_4 = self::factory()->comment->create( array(
    307307                        'comment_post_ID' => $p,
    308308                        'comment_content' => '4',
    309309                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    334334         */
    335335        public function test_last_page_of_comments_should_be_full_when_default_comment_page_is_newest() {
    336336                $now = time();
    337                 $p = self::$factory->post->create();
    338                 $comment_1 = self::$factory->comment->create( array(
     337                $p = self::factory()->post->create();
     338                $comment_1 = self::factory()->comment->create( array(
    339339                        'comment_post_ID' => $p,
    340340                        'comment_content' => '1',
    341341                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    342342                ) );
    343                 $comment_2 = self::$factory->comment->create( array(
     343                $comment_2 = self::factory()->comment->create( array(
    344344                        'comment_post_ID' => $p,
    345345                        'comment_content' => '2',
    346346                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    347347                ) );
    348                 $comment_3 = self::$factory->comment->create( array(
     348                $comment_3 = self::factory()->comment->create( array(
    349349                        'comment_post_ID' => $p,
    350350                        'comment_content' => '3',
    351351                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    376376         */
    377377        public function test_first_page_of_comments_should_have_remainder_when_default_comments_page_is_newest() {
    378378                $now = time();
    379                 $p = self::$factory->post->create();
    380                 $comment_1 = self::$factory->comment->create( array(
     379                $p = self::factory()->post->create();
     380                $comment_1 = self::factory()->comment->create( array(
    381381                        'comment_post_ID' => $p,
    382382                        'comment_content' => '1',
    383383                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    384384                ) );
    385                 $comment_2 = self::$factory->comment->create( array(
     385                $comment_2 = self::factory()->comment->create( array(
    386386                        'comment_post_ID' => $p,
    387387                        'comment_content' => '2',
    388388                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    389389                ) );
    390                 $comment_3 = self::$factory->comment->create( array(
     390                $comment_3 = self::factory()->comment->create( array(
    391391                        'comment_post_ID' => $p,
    392392                        'comment_content' => '3',
    393393                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    416416         */
    417417        public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_oldest() {
    418418                $now = time();
    419                 $p = self::$factory->post->create();
    420                 $comment_1 = self::$factory->comment->create( array(
     419                $p = self::factory()->post->create();
     420                $comment_1 = self::factory()->comment->create( array(
    421421                        'comment_post_ID' => $p,
    422422                        'comment_content' => '1',
    423423                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    424424                ) );
    425                 $comment_2 = self::$factory->comment->create( array(
     425                $comment_2 = self::factory()->comment->create( array(
    426426                        'comment_post_ID' => $p,
    427427                        'comment_content' => '2',
    428428                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    429429                ) );
    430                 $comment_3 = self::$factory->comment->create( array(
     430                $comment_3 = self::factory()->comment->create( array(
    431431                        'comment_post_ID' => $p,
    432432                        'comment_content' => '3',
    433433                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    434434                ) );
    435                 $comment_4 = self::$factory->comment->create( array(
     435                $comment_4 = self::factory()->comment->create( array(
    436436                        'comment_post_ID' => $p,
    437437                        'comment_content' => '4',
    438438                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { 
    480480         */
    481481        public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_newest() {
    482482                $now = time();
    483                 $p = self::$factory->post->create();
    484                 $comment_1 = self::$factory->comment->create( array(
     483                $p = self::factory()->post->create();
     484                $comment_1 = self::factory()->comment->create( array(
    485485                        'comment_post_ID' => $p,
    486486                        'comment_content' => '1',
    487487                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    488488                ) );
    489                 $comment_2 = self::$factory->comment->create( array(
     489                $comment_2 = self::factory()->comment->create( array(
    490490                        'comment_post_ID' => $p,
    491491                        'comment_content' => '2',
    492492                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    493493                ) );
    494                 $comment_3 = self::$factory->comment->create( array(
     494                $comment_3 = self::factory()->comment->create( array(
    495495                        'comment_post_ID' => $p,
    496496                        'comment_content' => '3',
    497497                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    498498                ) );
    499                 $comment_4 = self::$factory->comment->create( array(
     499                $comment_4 = self::factory()->comment->create( array(
    500500                        'comment_post_ID' => $p,
    501501                        'comment_content' => '4',
    502502                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    503503                ) );
    504                 $comment_5 = self::$factory->comment->create( array(
     504                $comment_5 = self::factory()->comment->create( array(
    505505                        'comment_post_ID' => $p,
    506506                        'comment_content' => '4',
    507507                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    508508                ) );
    509                 $comment_6 = self::$factory->comment->create( array(
     509                $comment_6 = self::factory()->comment->create( array(
    510510                        'comment_post_ID' => $p,
    511511                        'comment_content' => '4',
    512512                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
  • tests/phpunit/tests/comment/dateQuery.php

    diff --git tests/phpunit/tests/comment/dateQuery.php tests/phpunit/tests/comment/dateQuery.php
    index cccdb97..5859b5c 100644
    class Tests_Comment_DateQuery extends WP_UnitTestCase { 
    2222
    2323                // Just some dummy posts to use as parents for comments
    2424                for ( $i = 1; $i <= 2; $i++ ) {
    25                         $this->posts[$i] = self::$factory->post->create();
     25                        $this->posts[$i] = self::factory()->post->create();
    2626                }
    2727
    2828                // Be careful modifying this. Tests are coded to expect this exact sample data.
    class Tests_Comment_DateQuery extends WP_UnitTestCase { 
    3939                );
    4040
    4141                foreach ( $comment_dates as $comment_date => $comment_parent ) {
    42                         $result = self::$factory->comment->create( array(
     42                        $result = self::factory()->comment->create( array(
    4343                                'comment_date'    => $comment_date,
    4444                                'comment_post_ID' => $this->posts[ $comment_parent ],
    4545                        ) );
  • tests/phpunit/tests/comment/getCommentClass.php

    diff --git tests/phpunit/tests/comment/getCommentClass.php tests/phpunit/tests/comment/getCommentClass.php
    index 09bd5c8..a4518a2 100644
     
    55 */
    66class Tests_Comment_GetCommentClass extends WP_UnitTestCase {
    77        public function test_should_accept_comment_id() {
    8                 $post_id    = self::$factory->post->create();
    9                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     8                $post_id    = self::factory()->post->create();
     9                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    1010
    1111                $classes = get_comment_class( '', $comment_id );
    1212                $this->assertContains( 'comment', $classes );
    1313        }
    1414
    1515        public function test_should_accept_comment_object() {
    16                 $post_id = self::$factory->post->create();
    17                 $comment = self::$factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
     16                $post_id = self::factory()->post->create();
     17                $comment = self::factory()->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
    1818
    1919                $classes = get_comment_class( '', $comment );
    2020                $this->assertContains( 'comment', $classes );
    2121        }
    2222
    2323        public function test_should_append_single_class() {
    24                 $post_id    = self::$factory->post->create();
    25                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     24                $post_id    = self::factory()->post->create();
     25                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    2626
    2727                $classes = get_comment_class( 'foo', $comment_id );
    2828                $this->assertContains( 'foo', $classes );
    2929        }
    3030
    3131        public function test_should_append_array_of_classes() {
    32                 $post_id    = self::$factory->post->create();
    33                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     32                $post_id    = self::factory()->post->create();
     33                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    3434
    3535                $classes = get_comment_class( array( 'foo', 'bar' ), $comment_id );
    3636                $this->assertContains( 'foo', $classes );
  • tests/phpunit/tests/comment/getCommentCount.php

    diff --git tests/phpunit/tests/comment/getCommentCount.php tests/phpunit/tests/comment/getCommentCount.php
    index 45ba8e7..34e2219 100644
    class Tests_Get_Comment_Count extends WP_UnitTestCase { 
    1414        }
    1515
    1616        public function test_get_comment_count_approved() {
    17                 self::$factory->comment->create( array(
     17                self::factory()->comment->create( array(
    1818                        'comment_approved' => 1
    1919                ) );
    2020
    class Tests_Get_Comment_Count extends WP_UnitTestCase { 
    2929        }
    3030
    3131        public function test_get_comment_count_awaiting() {
    32                 self::$factory->comment->create( array(
     32                self::factory()->comment->create( array(
    3333                        'comment_approved' => 0
    3434                ) );
    3535
    class Tests_Get_Comment_Count extends WP_UnitTestCase { 
    4444        }
    4545
    4646        public function test_get_comment_count_spam() {
    47                 self::$factory->comment->create( array(
     47                self::factory()->comment->create( array(
    4848                        'comment_approved' => 'spam'
    4949                ) );
    5050
    class Tests_Get_Comment_Count extends WP_UnitTestCase { 
    5959        }
    6060
    6161        public function test_get_comment_count_trash() {
    62                 self::$factory->comment->create( array(
     62                self::factory()->comment->create( array(
    6363                        'comment_approved' => 'trash'
    6464                ) );
    6565
    class Tests_Get_Comment_Count extends WP_UnitTestCase { 
    7474        }
    7575
    7676        public function test_get_comment_count_post_trashed() {
    77                 self::$factory->comment->create( array(
     77                self::factory()->comment->create( array(
    7878                        'comment_approved' => 'post-trashed'
    7979                ) );
    8080
  • tests/phpunit/tests/comment/getCommentExcerpt.php

    diff --git tests/phpunit/tests/comment/getCommentExcerpt.php tests/phpunit/tests/comment/getCommentExcerpt.php
    index 6eee6e6..cfb66e7 100644
    Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco 
    1414        }
    1515
    1616        public function test_get_comment_excerpt() {
    17                 $comment_id = self::$factory->comment->create( array(
     17                $comment_id = self::factory()->comment->create( array(
    1818                        'comment_content' => self::$bacon_comment
    1919                ) );
    2020
    Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco 
    2424        }
    2525
    2626        public function test_get_comment_excerpt_filtered() {
    27                 $comment_id = self::$factory->comment->create( array(
     27                $comment_id = self::factory()->comment->create( array(
    2828                        'comment_content' => self::$bacon_comment
    2929                ) );
    3030
  • tests/phpunit/tests/comment/getCommentLink.php

    diff --git tests/phpunit/tests/comment/getCommentLink.php tests/phpunit/tests/comment/getCommentLink.php
    index 0b4e44c..c0ce30e 100644
    class Tests_Comment_GetCommentLink extends WP_UnitTestCase { 
    1111                parent::setUp();
    1212
    1313                $now = time();
    14                 $this->p = self::$factory->post->create();
    15                 $this->comments[] = self::$factory->comment->create( array(
     14                $this->p = self::factory()->post->create();
     15                $this->comments[] = self::factory()->comment->create( array(
    1616                        'comment_post_ID' => $this->p,
    1717                        'comment_content' => '1',
    1818                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    1919                ) );
    20                 $this->comments[] = self::$factory->comment->create( array(
     20                $this->comments[] = self::factory()->comment->create( array(
    2121                        'comment_post_ID' => $this->p,
    2222                        'comment_content' => '2',
    2323                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    2424                ) );
    25                 $this->comments[] = self::$factory->comment->create( array(
     25                $this->comments[] = self::factory()->comment->create( array(
    2626                        'comment_post_ID' => $this->p,
    2727                        'comment_content' => '3',
    2828                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    2929                ) );
    30                 $this->comments[] = self::$factory->comment->create( array(
     30                $this->comments[] = self::factory()->comment->create( array(
    3131                        'comment_post_ID' => $this->p,
    3232                        'comment_content' => '4',
    3333                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    3434                ) );
    35                 $this->comments[] = self::$factory->comment->create( array(
     35                $this->comments[] = self::factory()->comment->create( array(
    3636                        'comment_post_ID' => $this->p,
    3737                        'comment_content' => '4',
    3838                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    3939                ) );
    40                 $this->comments[] = self::$factory->comment->create( array(
     40                $this->comments[] = self::factory()->comment->create( array(
    4141                        'comment_post_ID' => $this->p,
    4242                        'comment_content' => '4',
    4343                        'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
  • tests/phpunit/tests/comment/getCommentsPagesCount.php

    diff --git tests/phpunit/tests/comment/getCommentsPagesCount.php tests/phpunit/tests/comment/getCommentsPagesCount.php
    index d6e21bc..9246f71 100644
    class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { 
    3838         */
    3939        function test_empty() {
    4040                //setup post and comments
    41                 $post_id = self::$factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
     41                $post_id = self::factory()->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
    4242                $this->go_to( '/?p=' . $post_id );
    4343
    4444                global $wp_query;
    class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { 
    6060         */
    6161        function test_threaded_comments( ) {
    6262                //setup post and comments
    63                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
    64                 $comments = self::$factory->comment->create_post_comments( $post->ID, 15 );
    65                 self::$factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) );
     63                $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
     64                $comments = self::factory()->comment->create_post_comments( $post->ID, 15 );
     65                self::factory()->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) );
    6666                $comments = get_comments( array( 'post_id' => $post->ID ) );
    6767
    6868                $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) );
    class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { 
    7676        function test_option_thread_comments() {
    7777
    7878                //setup post and comments
    79                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
    80                 $comments = self::$factory->comment->create_post_comments( $post->ID, 15 );
    81                 self::$factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) );
     79                $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) );
     80                $comments = self::factory()->comment->create_post_comments( $post->ID, 15 );
     81                self::factory()->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) );
    8282                $comments = get_comments( array( 'post_id' => $post->ID ) );
    8383
    8484                update_option( 'thread_comments', false );
    class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { 
    104104
    105105                update_option( 'posts_per_rss', 100 );
    106106
    107                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) );
    108                 $comments = self::$factory->comment->create_post_comments( $post->ID, 25 );
     107                $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) );
     108                $comments = self::factory()->comment->create_post_comments( $post->ID, 25 );
    109109
    110110                $wp_query = new WP_Query( array( 'p' => $post->ID, 'comments_per_page' => 10, 'feed' =>'comments-' ) );
    111111
  • tests/phpunit/tests/comment/getPageOfComment.php

    diff --git tests/phpunit/tests/comment/getPageOfComment.php tests/phpunit/tests/comment/getPageOfComment.php
    index 390b6ed..7de16a9 100644
     
    77class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
    88
    99        public function test_last_comment() {
    10                 $p = self::$factory->post->create();
     10                $p = self::factory()->post->create();
    1111
    1212                // page 4
    13                 $comment_last = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) );
    14                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) );
     13                $comment_last = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) );
     14                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) );
    1515
    1616                // page 3
    17                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) );
    18                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) );
    19                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) );
     17                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) );
     18                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) );
     19                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) );
    2020
    2121                // page 2
    22                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) );
    23                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) );
    24                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) );
     22                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) );
     23                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) );
     24                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) );
    2525
    2626                // page 1
    27                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) );
    28                 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );
    29                 $comment_first = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );
     27                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) );
     28                self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );
     29                $comment_first = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );
    3030
    3131                $this->assertEquals( 4, get_page_of_comment( $comment_last[0],  array( 'per_page' =>  3 ) ) );
    3232                $this->assertEquals( 2, get_page_of_comment( $comment_last[0],  array( 'per_page' => 10 ) ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    3636        }
    3737
    3838        public function test_type_pings() {
    39                 $p = self::$factory->post->create();
     39                $p = self::factory()->post->create();
    4040                $now = time();
    4141
    4242                $trackbacks = array();
    4343                for ( $i = 0; $i <= 3; $i++ ) {
    44                         $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
     44                        $trackbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
    4545                        $now -= 10 * $i;
    4646                }
    4747
    4848                $pingbacks = array();
    4949                for ( $i = 0; $i <= 6; $i++ ) {
    50                         $pingbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
     50                        $pingbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
    5151                        $now -= 10 * $i;
    5252                }
    5353
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    6262        public function test_subsequent_calls_should_hit_cache() {
    6363                global $wpdb;
    6464
    65                 $p = self::$factory->post->create();
    66                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     65                $p = self::factory()->post->create();
     66                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    6767
    6868                // Prime cache.
    6969                $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    8181        public function test_cache_hits_should_be_sensitive_to_comment_type() {
    8282                global $wpdb;
    8383
    84                 $p = self::$factory->post->create();
    85                 $comment = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) );
     84                $p = self::factory()->post->create();
     85                $comment = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) );
    8686
    8787                $now = time();
    8888                $trackbacks = array();
    8989                for ( $i = 0; $i <= 5; $i++ ) {
    90                         $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) );
     90                        $trackbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) );
    9191                }
    9292
    9393                // Prime cache for trackbacks.
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    105105         * @ticket 11334
    106106         */
    107107        public function test_cache_should_be_invalidated_when_comment_is_approved() {
    108                 $p = self::$factory->post->create();
    109                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) );
     108                $p = self::factory()->post->create();
     109                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) );
    110110
    111111                // Prime cache.
    112112                $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    121121         * @ticket 11334
    122122         */
    123123        public function test_cache_should_be_invalidated_when_comment_is_deleted() {
    124                 $p = self::$factory->post->create();
    125                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     124                $p = self::factory()->post->create();
     125                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    126126
    127127                // Prime cache.
    128128                $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    137137         * @ticket 11334
    138138         */
    139139        public function test_cache_should_be_invalidated_when_comment_is_spammed() {
    140                 $p = self::$factory->post->create();
    141                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     140                $p = self::factory()->post->create();
     141                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    142142
    143143                // Prime cache.
    144144                $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    155155        public function test_cache_should_be_invalidated_when_older_comment_is_published() {
    156156                $now = time();
    157157
    158                 $p = self::$factory->post->create();
    159                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
    160                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
    161                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
     158                $p = self::factory()->post->create();
     159                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
     160                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
     161                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
    162162
    163163                $this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
    164164
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    171171         * @ticket 34057
    172172         */
    173173        public function test_query_should_be_limited_to_comments_on_the_proper_post() {
    174                 $posts = self::$factory->post->create_many( 2 );
     174                $posts = self::factory()->post->create_many( 2 );
    175175
    176176                $now = time();
    177177                $comments_0 = $comments_1 = array();
    178178                for ( $i = 0; $i < 5; $i++ ) {
    179                         $comments_0[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
    180                         $comments_1[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     179                        $comments_0[] = self::factory()->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     180                        $comments_1[] = self::factory()->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
    181181                }
    182182
    183183                $found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) );
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    191191         * @ticket 13939
    192192         */
    193193        public function test_only_top_level_comments_should_be_included_in_older_count() {
    194                 $post = self::$factory->post->create();
     194                $post = self::factory()->post->create();
    195195
    196196                $now = time();
    197197                $comment_parents = $comment_children = array();
    198198                for ( $i = 0; $i < 5; $i++ ) {
    199                         $parent = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     199                        $parent = self::factory()->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
    200200                        $comment_parents[ $i ] = $parent;
    201201
    202                         $child = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );
     202                        $child = self::factory()->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );
    203203                        $comment_children[ $i ] = $child;
    204204                }
    205205
    class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { 
    228228        public function test_comments_per_page_option_should_be_fallback_when_query_var_is_not_available() {
    229229                $now = time();
    230230
    231                 $p = self::$factory->post->create();
    232                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
    233                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
    234                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
     231                $p = self::factory()->post->create();
     232                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );
     233                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );
     234                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );
    235235
    236236                update_option( 'comments_per_page', 2 );
    237237
  • tests/phpunit/tests/comment/metaCache.php

    diff --git tests/phpunit/tests/comment/metaCache.php tests/phpunit/tests/comment/metaCache.php
    index 6756325..166ad25 100644
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    1010        public function test_update_comment_meta_cache_should_default_to_true() {
    1111                global $wpdb;
    1212
    13                 $p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    14                 $comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
     13                $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     14                $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    1515
    1616                foreach ( $comment_ids as $cid ) {
    1717                        update_comment_meta( $cid, 'foo', 'bar' );
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    3838        public function test_update_comment_meta_cache_true() {
    3939                global $wpdb;
    4040
    41                 $p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    42                 $comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
     41                $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     42                $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    4343
    4444                foreach ( $comment_ids as $cid ) {
    4545                        update_comment_meta( $cid, 'foo', 'bar' );
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    6767        public function test_update_comment_meta_cache_false() {
    6868                global $wpdb;
    6969
    70                 $p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    71                 $comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
     70                $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     71                $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    7272
    7373                foreach ( $comment_ids as $cid ) {
    7474                        update_comment_meta( $cid, 'foo', 'bar' );
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    9393        public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() {
    9494                global $wpdb;
    9595
    96                 $p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    97                 $comment_ids = self::$factory->comment->create_post_comments( $p, 3 );
     96                $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     97                $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    9898
    9999                foreach ( $comment_ids as $cid ) {
    100100                        update_comment_meta( $cid, 'sauce', 'fire' );
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    128128        public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() {
    129129                global $wpdb;
    130130
    131                 $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
     131                $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
    132132
    133133                $now = time();
    134134                $comments = array();
    135135                for ( $i = 0; $i < 5; $i++ ) {
    136                         $comments[] = self::$factory->comment->create( array(
     136                        $comments[] = self::factory()->comment->create( array(
    137137                                'comment_post_ID' => $posts[0],
    138138                                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
    139139                        ) );
    class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 
    172172        public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() {
    173173                global $wpdb;
    174174
    175                 $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) );
     175                $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
    176176
    177177                $now = time();
    178178                $comments = array();
    179179                for ( $i = 0; $i < 5; $i++ ) {
    180                         $comments[] = self::$factory->comment->create( array(
     180                        $comments[] = self::factory()->comment->create( array(
    181181                                'comment_post_ID' => $posts[0],
    182182                                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
    183183                        ) );
  • tests/phpunit/tests/comment/query.php

    diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
    index 9a1c79b..4ccfe8c 100644
    class Tests_Comment_Query extends WP_UnitTestCase { 
    1212        function setUp() {
    1313                parent::setUp();
    1414
    15                 $this->post_id = self::$factory->post->create();
     15                $this->post_id = self::factory()->post->create();
    1616        }
    1717
    1818        public function test_query() {
    19                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    20                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    21                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    22                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    23                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     19                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     20                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     21                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     22                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     23                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    2424
    2525                $q = new WP_Comment_Query();
    2626                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    3131        }
    3232
    3333        public function test_query_post_id_0() {
    34                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     34                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    3535
    3636                $q = new WP_Comment_Query();
    3737                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    4646         * @ticket 12668
    4747         */
    4848        public function test_query_type_empty_string() {
    49                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    50                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    51                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    52                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    53                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     49                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     50                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     51                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     52                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     53                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    5454
    5555                $q = new WP_Comment_Query();
    5656                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    6565         * @ticket 12668
    6666         */
    6767        public function test_query_type_comment() {
    68                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    69                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    70                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    71                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    72                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     68                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     69                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     70                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     71                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     72                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    7373
    7474                $q = new WP_Comment_Query();
    7575                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    8181        }
    8282
    8383        public function test_query_type_pingback() {
    84                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    85                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    86                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    87                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     84                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     85                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     86                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     87                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    8888
    8989                $q = new WP_Comment_Query();
    9090                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    9797        }
    9898
    9999        public function test_query_type_trackback() {
    100                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    101                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    102                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    103                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     100                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     101                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     102                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     103                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    104104
    105105                $q = new WP_Comment_Query();
    106106                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    116116         * 'pings' is an alias for 'trackback' + 'pingback'.
    117117         */
    118118        public function test_query_type_pings() {
    119                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    120                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    121                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    122                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    123                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     119                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     120                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     121                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     122                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     123                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    124124
    125125                $q = new WP_Comment_Query();
    126126                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    136136         * @ticket 12668
    137137         */
    138138        public function test_type_array_comments_and_custom() {
    139                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    140                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    141                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    142                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    143                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    144                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     139                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     140                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     141                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     142                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     143                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     144                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    145145
    146146                $q = new WP_Comment_Query();
    147147                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    156156         * @ticket 12668
    157157         */
    158158        public function test_type_not__in_array_custom() {
    159                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    160                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    161                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    162                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    163                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    164                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     159                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     160                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     161                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     162                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     163                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     164                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    165165
    166166                $q = new WP_Comment_Query();
    167167                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    176176         * @ticket 12668
    177177         */
    178178        public function test_type__in_array_and_not_type_array_custom() {
    179                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    180                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    181                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    182                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    183                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    184                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     179                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     180                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     181                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     182                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     183                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     184                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    185185
    186186                $q = new WP_Comment_Query();
    187187                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    197197         * @ticket 12668
    198198         */
    199199        public function test_type_array_and_type__not_in_array_custom() {
    200                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    201                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    202                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    203                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    204                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    205                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     200                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     201                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     202                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     203                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     204                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     205                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    206206
    207207                $q = new WP_Comment_Query();
    208208                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    218218         * @ticket 12668
    219219         */
    220220        public function test_type__not_in_custom() {
    221                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    222                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    223                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    224                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    225                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    226                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     221                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     222                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     223                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     224                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     225                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     226                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    227227
    228228                $q = new WP_Comment_Query();
    229229                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    238238         * @ticket 12668
    239239         */
    240240        public function test_type_array_comments_and_pings() {
    241                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    242                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    243                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    244                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
    245                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
     241                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     242                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     243                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     244                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
     245                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
    246246
    247247                $q = new WP_Comment_Query();
    248248                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    257257         * @ticket 12668
    258258         */
    259259        public function test_type_array_comment_pings() {
    260                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    261                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    262                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     260                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     261                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     262                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    263263
    264264                $q = new WP_Comment_Query();
    265265                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    274274         * @ticket 12668
    275275         */
    276276        public function test_type_array_pingback() {
    277                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    278                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    279                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     277                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     278                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     279                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    280280
    281281                $q = new WP_Comment_Query();
    282282                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    291291         * @ticket 12668
    292292         */
    293293        public function test_type_array_custom_pingpack() {
    294                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    295                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    296                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     294                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     295                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     296                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    297297
    298298                $q = new WP_Comment_Query();
    299299                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    308308         * @ticket 12668
    309309         */
    310310        public function test_type_array_pings() {
    311                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    312                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    313                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     311                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     312                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     313                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    314314
    315315                $q = new WP_Comment_Query();
    316316                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    325325         * @ticket 12668
    326326         */
    327327        public function test_type_status_approved_array_comment_pings() {
    328                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    329                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    330                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    331                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) );
     328                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     329                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     330                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     331                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) );
    332332
    333333                $q = new WP_Comment_Query();
    334334                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    344344         * @ticket 12668
    345345         */
    346346        public function test_type_array_trackback() {
    347                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    348                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    349                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     347                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     348                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     349                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    350350
    351351                $q = new WP_Comment_Query();
    352352                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    361361         * @ticket 12668
    362362         */
    363363        public function test_type_array_custom_trackback() {
    364                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    365                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    366                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
     364                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     365                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     366                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
    367367
    368368                $q = new WP_Comment_Query();
    369369                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    378378         * @ticket 12668
    379379         */
    380380        public function test_type_array_pings_approved() {
    381                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    382                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    383                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
    384                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) );
     381                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     382                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     383                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
     384                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) );
    385385
    386386                $q = new WP_Comment_Query();
    387387                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    397397         * @ticket 29612
    398398         */
    399399        public function test_status_empty_string() {
    400                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    401                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    402                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) );
     400                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     401                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     402                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) );
    403403
    404404                $q = new WP_Comment_Query();
    405405                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    414414         * @ticket 21101
    415415         */
    416416        public function test_status_hold() {
    417                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    418                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     417                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     418                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    419419
    420420                $q = new WP_Comment_Query();
    421421                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    430430         * @ticket 21101
    431431         */
    432432        public function test_status_approve() {
    433                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    434                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     433                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     434                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    435435
    436436                $q = new WP_Comment_Query();
    437437                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    443443        }
    444444
    445445        public function test_status_custom() {
    446                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    447                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    448                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) );
     446                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     447                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     448                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) );
    449449
    450450                $q = new WP_Comment_Query();
    451451                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    457457        }
    458458
    459459        public function test_status_all() {
    460                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    461                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    462                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     460                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     461                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     462                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    463463
    464464                $q = new WP_Comment_Query();
    465465                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    471471        }
    472472
    473473        public function test_status_default_to_all() {
    474                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    475                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    476                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     474                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     475                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     476                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    477477
    478478                $q = new WP_Comment_Query();
    479479                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    487487         * @ticket 29612
    488488         */
    489489        public function test_status_comma_any() {
    490                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    491                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    492                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     490                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     491                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     492                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    493493
    494494                $q = new WP_Comment_Query();
    495495                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    504504         * @ticket 29612
    505505         */
    506506        public function test_status_comma_separated() {
    507                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    508                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    509                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     507                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     508                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     509                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    510510
    511511                $q = new WP_Comment_Query();
    512512                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    521521         * @ticket 29612
    522522         */
    523523        public function test_status_array() {
    524                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    525                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
    526                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
     524                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     525                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) );
     526                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) );
    527527
    528528                $q = new WP_Comment_Query();
    529529                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    537537        function test_get_comments_for_post() {
    538538                $limit = 5;
    539539
    540                 $post_id = self::$factory->post->create();
    541                 self::$factory->comment->create_post_comments( $post_id, $limit );
     540                $post_id = self::factory()->post->create();
     541                self::factory()->comment->create_post_comments( $post_id, $limit );
    542542                $comments = get_comments( array( 'post_id' => $post_id ) );
    543543                $this->assertEquals( $limit, count( $comments ) );
    544544                foreach ( $comments as $comment ) {
    545545                        $this->assertEquals( $post_id, $comment->comment_post_ID );
    546546                }
    547547
    548                 $post_id2 = self::$factory->post->create();
    549                 self::$factory->comment->create_post_comments( $post_id2, $limit );
     548                $post_id2 = self::factory()->post->create();
     549                self::factory()->comment->create_post_comments( $post_id2, $limit );
    550550                $comments = get_comments( array( 'post_id' => $post_id2 ) );
    551551                $this->assertEquals( $limit, count( $comments ) );
    552552                foreach ( $comments as $comment ) {
    553553                        $this->assertEquals( $post_id2, $comment->comment_post_ID );
    554554                }
    555555
    556                 $post_id3 = self::$factory->post->create();
    557                 self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) );
     556                $post_id3 = self::factory()->post->create();
     557                self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) );
    558558                $comments = get_comments( array( 'post_id' => $post_id3 ) );
    559559                $this->assertEquals( $limit, count( $comments ) );
    560560                foreach ( $comments as $comment ) {
    class Tests_Comment_Query extends WP_UnitTestCase { 
    570570                $comments = get_comments( array( 'post_id' => $post_id3, 'status' => 'approve' ) );
    571571                $this->assertEquals( 0, count( $comments ) );
    572572
    573                 self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) );
     573                self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) );
    574574                $comments = get_comments( array( 'post_id' => $post_id3 ) );
    575575                $this->assertEquals( $limit * 2, count( $comments ) );
    576576                foreach ( $comments as $comment ) {
    class Tests_Comment_Query extends WP_UnitTestCase { 
    582582         * @ticket 21003
    583583         */
    584584        function test_orderby_meta() {
    585                 $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    586                 $comment_id2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    587                 $comment_id3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     585                $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     586                $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     587                $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    588588
    589589                add_comment_meta( $comment_id, 'key', 'value1', true );
    590590                add_comment_meta( $comment_id, 'key1', 'value1', true );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    632632         * @ticket 30478
    633633         */
    634634        public function test_orderby_clause_key() {
    635                 $comments = self::$factory->comment->create_many( 3 );
     635                $comments = self::factory()->comment->create_many( 3 );
    636636                add_comment_meta( $comments[0], 'foo', 'aaa' );
    637637                add_comment_meta( $comments[1], 'foo', 'zzz' );
    638638                add_comment_meta( $comments[2], 'foo', 'jjj' );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    657657         * @ticket 30478
    658658         */
    659659        public function test_orderby_clause_key_as_secondary_sort() {
    660                 $c1 = self::$factory->comment->create( array(
     660                $c1 = self::factory()->comment->create( array(
    661661                        'comment_date' => '2015-01-28 03:00:00',
    662662                ) );
    663                 $c2 = self::$factory->comment->create( array(
     663                $c2 = self::factory()->comment->create( array(
    664664                        'comment_date' => '2015-01-28 05:00:00',
    665665                ) );
    666                 $c3 = self::$factory->comment->create( array(
     666                $c3 = self::factory()->comment->create( array(
    667667                        'comment_date' => '2015-01-28 03:00:00',
    668668                ) );
    669669
    class Tests_Comment_Query extends WP_UnitTestCase { 
    693693         * @ticket 30478
    694694         */
    695695        public function test_orderby_more_than_one_clause_key() {
    696                 $comments = self::$factory->comment->create_many( 3 );
     696                $comments = self::factory()->comment->create_many( 3 );
    697697
    698698                add_comment_meta( $comments[0], 'foo', 'jjj' );
    699699                add_comment_meta( $comments[1], 'foo', 'zzz' );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    728728         * @group 32081
    729729         */
    730730        public function test_meta_query_should_work_with_comment__in() {
    731                 $comments = self::$factory->comment->create_many( 3 );
     731                $comments = self::factory()->comment->create_many( 3 );
    732732
    733733                add_comment_meta( $comments[0], 'foo', 'jjj' );
    734734                add_comment_meta( $comments[1], 'foo', 'zzz' );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    752752         * @group 32081
    753753         */
    754754        public function test_meta_query_should_work_with_comment__not_in() {
    755                 $comments = self::$factory->comment->create_many( 3 );
     755                $comments = self::factory()->comment->create_many( 3 );
    756756
    757757                add_comment_meta( $comments[0], 'foo', 'jjj' );
    758758                add_comment_meta( $comments[1], 'foo', 'zzz' );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    776776         * @ticket 27064
    777777         */
    778778        function test_get_comments_by_user() {
    779                 $users = self::$factory->user->create_many( 2 );
    780                 self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    781                 self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    782                 self::$factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     779                $users = self::factory()->user->create_many( 2 );
     780                self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     781                self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     782                self::factory()->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    783783
    784784                $comments = get_comments( array(
    785785                        'user_id' => $users[0],
    class Tests_Comment_Query extends WP_UnitTestCase { 
    808808         * @ticket 28434
    809809         */
    810810        function test_fields_ids_query() {
    811                 $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    812                 $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    813                 $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     811                $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     812                $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     813                $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    814814
    815815                // Ensure we are dealing with integers, and not objects.
    816816                $this->assertInternalType( 'integer', $comment_1 );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    826826         * @ticket 29189
    827827         */
    828828        function test_fields_comment__in() {
    829                 $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    830                 $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    831                 $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     829                $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     830                $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     831                $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    832832
    833833                $comment_ids = get_comments( array(
    834834                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    842842         * @ticket 29189
    843843         */
    844844        function test_fields_comment__not_in() {
    845                 $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    846                 $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    847                 $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     845                $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     846                $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     847                $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    848848
    849849                $comment_ids = get_comments( array(
    850850                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    858858         * @ticket 29189
    859859         */
    860860        function test_fields_post__in() {
    861                 $p1 = self::$factory->post->create();
    862                 $p2 = self::$factory->post->create();
    863                 $p3 = self::$factory->post->create();
     861                $p1 = self::factory()->post->create();
     862                $p2 = self::factory()->post->create();
     863                $p3 = self::factory()->post->create();
    864864
    865                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
    866                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
    867                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     865                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
     866                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     867                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
    868868
    869869                $comment_ids = get_comments( array(
    870870                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    878878         * @ticket 29189
    879879         */
    880880        function test_fields_post__not_in() {
    881                 $p1 = self::$factory->post->create();
    882                 $p2 = self::$factory->post->create();
    883                 $p3 = self::$factory->post->create();
     881                $p1 = self::factory()->post->create();
     882                $p2 = self::factory()->post->create();
     883                $p3 = self::factory()->post->create();
    884884
    885                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
    886                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
    887                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     885                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
     886                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     887                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
    888888
    889889                $comment_ids = get_comments( array(
    890890                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    901901                $author_id1 = 105;
    902902                $author_id2 = 106;
    903903
    904                 $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) );
    905                 $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) );
    906                 $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) );
     904                $p1 = self::factory()->post->create( array( 'post_author' => $author_id1        ) );
     905                $p2 = self::factory()->post->create( array( 'post_author' => $author_id1        ) );
     906                $p3 = self::factory()->post->create( array( 'post_author' => $author_id2        ) );
    907907
    908                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
    909                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
    910                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     908                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
     909                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     910                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
    911911
    912912                $comment_ids = get_comments( array(
    913913                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    924924                $author_id1 = 111;
    925925                $author_id2 = 112;
    926926
    927                 $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) );
    928                 $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) );
    929                 $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) );
     927                $p1 = self::factory()->post->create( array( 'post_author' => $author_id1        ) );
     928                $p2 = self::factory()->post->create( array( 'post_author' => $author_id1        ) );
     929                $p3 = self::factory()->post->create( array( 'post_author' => $author_id2        ) );
    930930
    931                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
    932                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
    933                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     931                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
     932                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     933                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
    934934
    935935                $comment_ids = get_comments( array(
    936936                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    944944         * @ticket 29885
    945945         */
    946946        function test_fields_author__in() {
    947                 $p1 = self::$factory->post->create();
    948                 $p2 = self::$factory->post->create();
    949                 $p3 = self::$factory->post->create();
    950                 $p4 = self::$factory->post->create();
     947                $p1 = self::factory()->post->create();
     948                $p2 = self::factory()->post->create();
     949                $p3 = self::factory()->post->create();
     950                $p4 = self::factory()->post->create();
    951951
    952                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
    953                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) );
    954                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) );
    955                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) );
     952                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
     953                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) );
     954                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) );
     955                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) );
    956956
    957957                $comment_ids = get_comments( array(
    958958                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    966966         * @ticket 29885
    967967         */
    968968        function test_fields_author__not_in() {
    969                 $p1 = self::$factory->post->create();
    970                 $p2 = self::$factory->post->create();
    971                 $p3 = self::$factory->post->create();
    972                 $p4 = self::$factory->post->create();
     969                $p1 = self::factory()->post->create();
     970                $p2 = self::factory()->post->create();
     971                $p3 = self::factory()->post->create();
     972                $p4 = self::factory()->post->create();
    973973
    974                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
    975                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) );
    976                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) );
    977                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) );
     974                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) );
     975                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) );
     976                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) );
     977                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) );
    978978
    979979                $comment_ids = get_comments( array(
    980980                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    988988         * @ticket 19623
    989989         */
    990990        public function test_get_comments_with_status_all() {
    991                 $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    992                 $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    993                 $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
     991                $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     992                $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     993                $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
    994994                $comments_approved_1 = get_comments( array( 'status' => 'all' ) );
    995995
    996996                $comment_ids = get_comments( array( 'fields' => 'ids' ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10011001         * @ticket 19623
    10021002         */
    10031003        public function test_get_comments_with_include_unapproved_user_id() {
    1004                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1005                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    1006                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
    1007                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
     1004                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1005                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     1006                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
     1007                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
    10081008
    10091009                $found = get_comments( array(
    10101010                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10191019         * @ticket 19623
    10201020         */
    10211021        public function test_get_comments_with_include_unapproved_user_id_array() {
    1022                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1023                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    1024                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
    1025                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
    1026                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) );
     1022                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1023                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     1024                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
     1025                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
     1026                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) );
    10271027
    10281028                $found = get_comments( array(
    10291029                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10381038         * @ticket 19623
    10391039         */
    10401040        public function test_get_comments_with_include_unapproved_user_id_comma_separated() {
    1041                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1042                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
    1043                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
    1044                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
    1045                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) );
     1041                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1042                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     1043                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) );
     1044                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) );
     1045                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) );
    10461046
    10471047                $found = get_comments( array(
    10481048                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10571057         * @ticket 19623
    10581058         */
    10591059        public function test_get_comments_with_include_unapproved_author_email() {
    1060                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1061                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1062                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1063                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1060                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1061                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1062                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1063                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    10641064
    10651065                $found = get_comments( array(
    10661066                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10751075         * @ticket 19623
    10761076         */
    10771077        public function test_get_comments_with_include_unapproved_mixed_array() {
    1078                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1079                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1080                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1081                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    1082                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1078                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1079                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1080                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1081                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1082                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    10831083
    10841084                $found = get_comments( array(
    10851085                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    10941094         * @ticket 19623
    10951095         */
    10961096        public function test_get_comments_with_include_unapproved_mixed_comma_separated() {
    1097                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
    1098                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1099                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
    1100                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    1101                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1097                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     1098                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1099                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) );
     1100                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1101                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    11021102
    11031103                $found = get_comments( array(
    11041104                        'fields' => 'ids',
    class Tests_Comment_Query extends WP_UnitTestCase { 
    11101110        }
    11111111
    11121112        public function test_search() {
    1113                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
    1114                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) );
    1115                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) );
    1116                 $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) );
    1117                 $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) );
    1118                 $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) );
     1113                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) );
     1114                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) );
     1115                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) );
     1116                $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) );
     1117                $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) );
     1118                $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) );
    11191119
    11201120                $q = new WP_Comment_Query();
    11211121                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    13631363         */
    13641364        public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() {
    13651365                $now = current_time( 'mysql', 1 );
    1366                 $comments = self::$factory->comment->create_many( 5, array(
     1366                $comments = self::factory()->comment->create_many( 5, array(
    13671367                        'comment_post_ID' => $this->post_id,
    13681368                        'comment_date_gmt' => $now,
    13691369                ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    13831383         */
    13841384        public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() {
    13851385                $now = current_time( 'mysql', 1 );
    1386                 $comments = self::$factory->comment->create_many( 5, array(
     1386                $comments = self::factory()->comment->create_many( 5, array(
    13871387                        'comment_post_ID' => $this->post_id,
    13881388                        'comment_date_gmt' => $now,
    13891389                ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    14161416        }
    14171417
    14181418        public function test_count() {
    1419                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
    1420                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
     1419                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
     1420                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
    14211421
    14221422                $q = new WP_Comment_Query();
    14231423                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    14311431         * @ticket 23369
    14321432         */
    14331433        public function test_count_with_meta_query() {
    1434                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
    1435                 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
    1436                 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
     1434                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
     1435                $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
     1436                $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
    14371437                add_comment_meta( $c1, 'foo', 'bar' );
    14381438                add_comment_meta( $c3, 'foo', 'bar' );
    14391439
    class Tests_Comment_Query extends WP_UnitTestCase { 
    14551455                register_post_type( 'post-type-1' );
    14561456                register_post_type( 'post-type-2' );
    14571457
    1458                 $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) );
    1459                 $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) );
     1458                $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) );
     1459                $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) );
    14601460
    1461                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1462                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1461                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1462                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    14631463
    14641464                $q = new WP_Comment_Query();
    14651465                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    14801480                register_post_type( 'post-type-1' );
    14811481                register_post_type( 'post-type-2' );
    14821482
    1483                 $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) );
    1484                 $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) );
     1483                $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) );
     1484                $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) );
    14851485
    1486                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1487                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1486                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1487                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    14881488
    14891489                $q = new WP_Comment_Query();
    14901490                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    15051505                register_post_type( 'post-type-1' );
    15061506                register_post_type( 'post-type-2' );
    15071507
    1508                 $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) );
    1509                 $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) );
    1510                 $p3 = self::$factory->post->create( array( 'post_type' => 'post-type-3' ) );
     1508                $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) );
     1509                $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) );
     1510                $p3 = self::factory()->post->create( array( 'post_type' => 'post-type-3' ) );
    15111511
    1512                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1513                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
    1514                 $c3 = self::$factory->comment->create_post_comments( $p3, 1 );
     1512                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1513                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
     1514                $c3 = self::factory()->comment->create_post_comments( $p3, 1 );
    15151515
    15161516                $q = new WP_Comment_Query();
    15171517                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    15261526        }
    15271527
    15281528        public function test_post_name_single_value() {
    1529                 $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) );
    1530                 $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) );
     1529                $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) );
     1530                $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) );
    15311531
    1532                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1533                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1532                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1533                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    15341534
    15351535                $q = new WP_Comment_Query();
    15361536                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    15451545         * @ticket 20006
    15461546         */
    15471547        public function test_post_name_singleton_array() {
    1548                 $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) );
    1549                 $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) );
     1548                $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) );
     1549                $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) );
    15501550
    1551                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1552                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1551                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1552                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    15531553
    15541554                $q = new WP_Comment_Query();
    15551555                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    15641564         * @ticket 20006
    15651565         */
    15661566        public function test_post_name_array() {
    1567                 $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) );
    1568                 $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) );
    1569                 $p3 = self::$factory->post->create( array( 'post_name' => 'baz' ) );
     1567                $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) );
     1568                $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) );
     1569                $p3 = self::factory()->post->create( array( 'post_name' => 'baz' ) );
    15701570
    1571                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1572                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
    1573                 $c3 = self::$factory->comment->create_post_comments( $p3, 1 );
     1571                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1572                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
     1573                $c3 = self::factory()->comment->create_post_comments( $p3, 1 );
    15741574
    15751575                $q = new WP_Comment_Query();
    15761576                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    15821582        }
    15831583
    15841584        public function test_post_status_single_value() {
    1585                 $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    1586                 $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) );
     1585                $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1586                $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    15871587
    1588                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1589                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1588                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1589                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    15901590
    15911591                $q = new WP_Comment_Query();
    15921592                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16011601         * @ticket 20006
    16021602         */
    16031603        public function test_post_status_singleton_array() {
    1604                 $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    1605                 $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) );
     1604                $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1605                $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    16061606
    1607                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1608                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
     1607                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1608                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
    16091609
    16101610                $q = new WP_Comment_Query();
    16111611                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16201620         * @ticket 20006
    16211621         */
    16221622        public function test_post_status_array() {
    1623                 $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
    1624                 $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) );
    1625                 $p3 = self::$factory->post->create( array( 'post_status' => 'future' ) );
     1623                $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     1624                $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) );
     1625                $p3 = self::factory()->post->create( array( 'post_status' => 'future' ) );
    16261626
    1627                 $c1 = self::$factory->comment->create_post_comments( $p1, 1 );
    1628                 $c2 = self::$factory->comment->create_post_comments( $p2, 1 );
    1629                 $c3 = self::$factory->comment->create_post_comments( $p3, 1 );
     1627                $c1 = self::factory()->comment->create_post_comments( $p1, 1 );
     1628                $c2 = self::factory()->comment->create_post_comments( $p2, 1 );
     1629                $c3 = self::factory()->comment->create_post_comments( $p3, 1 );
    16301630
    16311631                $q = new WP_Comment_Query();
    16321632                $found = $q->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16411641         * @ticket 24826
    16421642         */
    16431643        public function test_comment_query_object() {
    1644                 $comment_id = self::$factory->comment->create();
     1644                $comment_id = self::factory()->comment->create();
    16451645
    16461646                $query1 = new WP_Comment_Query();
    16471647                $this->assertNull( $query1->query_vars );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16631663        public function test_comment_cache_key_should_ignore_custom_params() {
    16641664                global $wpdb;
    16651665
    1666                 $p = self::$factory->post->create();
    1667                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     1666                $p = self::factory()->post->create();
     1667                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    16681668
    16691669                $q1 = new WP_Comment_Query();
    16701670                $q1->query( array(
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16881688         * @ticket 32762
    16891689         */
    16901690        public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() {
    1691                 $comments = self::$factory->comment->create_many( 2, array(
     1691                $comments = self::factory()->comment->create_many( 2, array(
    16921692                        'comment_post_ID' => $this->post_id,
    16931693                ) );
    16941694
    class Tests_Comment_Query extends WP_UnitTestCase { 
    17191719         * @ticket 32762
    17201720         */
    17211721        public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() {
    1722                 $comments = self::$factory->comment->create_many( 2, array(
     1722                $comments = self::factory()->comment->create_many( 2, array(
    17231723                        'comment_post_ID' => $this->post_id,
    17241724                ) );
    17251725
    class Tests_Comment_Query extends WP_UnitTestCase { 
    17461746         * @ticket 33882
    17471747         */
    17481748        public function test_parent__in() {
    1749                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    1750                 $c2 = self::$factory->comment->create( array(
     1749                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     1750                $c2 = self::factory()->comment->create( array(
    17511751                        'comment_post_ID' => $this->post_id,
    17521752                        'comment_approved' => '1',
    17531753                        'comment_parent' => $c1,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    17661766         * @ticket 33882
    17671767         */
    17681768        public function test_parent__in_commas() {
    1769                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    1770                 $c2 = self::$factory->comment->create( array(
     1769                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     1770                $c2 = self::factory()->comment->create( array(
    17711771                        'comment_post_ID' => $this->post_id,
    17721772                        'comment_approved' => '1'
    17731773                ) );
    1774                 $c3 = self::$factory->comment->create( array(
     1774                $c3 = self::factory()->comment->create( array(
    17751775                        'comment_post_ID' => $this->post_id,
    17761776                        'comment_approved' => '1',
    17771777                        'comment_parent' => $c1,
    17781778                ) );
    1779                 $c4 = self::$factory->comment->create( array(
     1779                $c4 = self::factory()->comment->create( array(
    17801780                        'comment_post_ID' => $this->post_id,
    17811781                        'comment_approved' => '1',
    17821782                        'comment_parent' => $c2,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    17951795         * @ticket 33882
    17961796         */
    17971797        public function test_parent__not_in() {
    1798                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     1798                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    17991799
    1800                 self::$factory->comment->create( array(
     1800                self::factory()->comment->create( array(
    18011801                        'comment_post_ID' => $this->post_id,
    18021802                        'comment_approved' => '1',
    18031803                        'comment_parent' => $c1,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    18161816         * @ticket 33882
    18171817         */
    18181818        public function test_parent__not_in_commas() {
    1819                 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
    1820                 $c2 = self::$factory->comment->create( array(
     1819                $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     1820                $c2 = self::factory()->comment->create( array(
    18211821                        'comment_post_ID' => $this->post_id,
    18221822                        'comment_approved' => '1'
    18231823                ) );
    18241824
    1825                 self::$factory->comment->create( array(
     1825                self::factory()->comment->create( array(
    18261826                        'comment_post_ID' => $this->post_id,
    18271827                        'comment_approved' => '1',
    18281828                        'comment_parent' => $c1,
    18291829                ) );
    1830                 self::$factory->comment->create( array(
     1830                self::factory()->comment->create( array(
    18311831                        'comment_post_ID' => $this->post_id,
    18321832                        'comment_approved' => '1',
    18331833                        'comment_parent' => $c2,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    18461846         * @ticket 33883
    18471847         */
    18481848        public function test_orderby_comment__in() {
    1849                 self::$factory->comment->create( array(
     1849                self::factory()->comment->create( array(
    18501850                        'comment_post_ID' => $this->post_id,
    18511851                        'comment_approved' => '1'
    18521852                ) );
    18531853
    1854                 $c2 = self::$factory->comment->create( array(
     1854                $c2 = self::factory()->comment->create( array(
    18551855                        'comment_post_ID' => $this->post_id,
    18561856                        'comment_approved' => '1'
    18571857                ) );
    1858                 $c3 = self::$factory->comment->create( array(
     1858                $c3 = self::factory()->comment->create( array(
    18591859                        'comment_post_ID' => $this->post_id,
    18601860                        'comment_approved' => '1'
    18611861                ) );
    18621862
    1863                 self::$factory->comment->create( array(
     1863                self::factory()->comment->create( array(
    18641864                        'comment_post_ID' => $this->post_id,
    18651865                        'comment_approved' => '1'
    18661866                ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    18801880         * @ticket 8071
    18811881         */
    18821882        public function test_no_found_rows_should_default_to_true() {
    1883                 $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
     1883                $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
    18841884
    18851885                $q = new WP_Comment_Query( array(
    18861886                        'post_id' => $this->post_id,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    18951895         * @ticket 8071
    18961896         */
    18971897        public function test_should_respect_no_found_rows_true() {
    1898                 $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
     1898                $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
    18991899
    19001900                $q = new WP_Comment_Query( array(
    19011901                        'post_id' => $this->post_id,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    19111911         * @ticket 8071
    19121912         */
    19131913        public function test_should_respect_no_found_rows_false() {
    1914                 $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
     1914                $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) );
    19151915
    19161916                $q = new WP_Comment_Query( array(
    19171917                        'post_id' => $this->post_id,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    19271927         * @ticket 8071
    19281928         */
    19291929        public function test_hierarchical_should_skip_child_comments_in_offset() {
    1930                 $top_level_0 = self::$factory->comment->create( array(
     1930                $top_level_0 = self::factory()->comment->create( array(
    19311931                        'comment_post_ID' => $this->post_id,
    19321932                        'comment_approved' => '1',
    19331933                ) );
    19341934
    1935                 $child_of_0 = self::$factory->comment->create( array(
     1935                $child_of_0 = self::factory()->comment->create( array(
    19361936                        'comment_post_ID' => $this->post_id,
    19371937                        'comment_approved' => '1',
    19381938                        'comment_parent' => $top_level_0,
    19391939                ) );
    19401940
    1941                 $top_level_comments = self::$factory->comment->create_many( 3, array(
     1941                $top_level_comments = self::factory()->comment->create_many( 3, array(
    19421942                        'comment_post_ID' => $this->post_id,
    19431943                        'comment_approved' => '1',
    19441944                ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    19601960         * @ticket 8071
    19611961         */
    19621962        public function test_hierarchical_should_not_include_child_comments_in_number() {
    1963                 $top_level_0 = self::$factory->comment->create( array(
     1963                $top_level_0 = self::factory()->comment->create( array(
    19641964                        'comment_post_ID' => $this->post_id,
    19651965                        'comment_approved' => '1',
    19661966                ) );
    19671967
    1968                 $child_of_0 = self::$factory->comment->create( array(
     1968                $child_of_0 = self::factory()->comment->create( array(
    19691969                        'comment_post_ID' => $this->post_id,
    19701970                        'comment_approved' => '1',
    19711971                        'comment_parent' => $top_level_0,
    19721972                ) );
    19731973
    1974                 $top_level_comments = self::$factory->comment->create_many( 3, array(
     1974                $top_level_comments = self::factory()->comment->create_many( 3, array(
    19751975                        'comment_post_ID' => $this->post_id,
    19761976                        'comment_approved' => '1',
    19771977                ) );
    class Tests_Comment_Query extends WP_UnitTestCase { 
    19911991         * @ticket 8071
    19921992         */
    19931993        public function test_hierarchical_threaded() {
    1994                 $c1 = self::$factory->comment->create( array(
     1994                $c1 = self::factory()->comment->create( array(
    19951995                        'comment_post_ID' => $this->post_id,
    19961996                        'comment_approved' => '1',
    19971997                ) );
    19981998
    1999                 $c2 = self::$factory->comment->create( array(
     1999                $c2 = self::factory()->comment->create( array(
    20002000                        'comment_post_ID' => $this->post_id,
    20012001                        'comment_approved' => '1',
    20022002                        'comment_parent' => $c1,
    20032003                ) );
    20042004
    2005                 $c3 = self::$factory->comment->create( array(
     2005                $c3 = self::factory()->comment->create( array(
    20062006                        'comment_post_ID' => $this->post_id,
    20072007                        'comment_approved' => '1',
    20082008                        'comment_parent' => $c2,
    20092009                ) );
    20102010
    2011                 $c4 = self::$factory->comment->create( array(
     2011                $c4 = self::factory()->comment->create( array(
    20122012                        'comment_post_ID' => $this->post_id,
    20132013                        'comment_approved' => '1',
    20142014                        'comment_parent' => $c1,
    20152015                ) );
    20162016
    2017                 $c5 = self::$factory->comment->create( array(
     2017                $c5 = self::factory()->comment->create( array(
    20182018                        'comment_post_ID' => $this->post_id,
    20192019                        'comment_approved' => '1',
    20202020                ) );
    20212021
    2022                 $c6 = self::$factory->comment->create( array(
     2022                $c6 = self::factory()->comment->create( array(
    20232023                        'comment_post_ID' => $this->post_id,
    20242024                        'comment_approved' => '1',
    20252025                        'comment_parent' => $c5,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    20542054         * @ticket 8071
    20552055         */
    20562056        public function test_hierarchical_threaded_approved() {
    2057                 $c1 = self::$factory->comment->create( array(
     2057                $c1 = self::factory()->comment->create( array(
    20582058                        'comment_post_ID' => $this->post_id,
    20592059                        'comment_approved' => '1',
    20602060                ) );
    20612061
    2062                 $c2 = self::$factory->comment->create( array(
     2062                $c2 = self::factory()->comment->create( array(
    20632063                        'comment_post_ID' => $this->post_id,
    20642064                        'comment_approved' => '1',
    20652065                        'comment_parent' => $c1,
    20662066                ) );
    20672067
    2068                 $c3 = self::$factory->comment->create( array(
     2068                $c3 = self::factory()->comment->create( array(
    20692069                        'comment_post_ID' => $this->post_id,
    20702070                        'comment_approved' => '0',
    20712071                        'comment_parent' => $c2,
    20722072                ) );
    20732073
    2074                 $c4 = self::$factory->comment->create( array(
     2074                $c4 = self::factory()->comment->create( array(
    20752075                        'comment_post_ID' => $this->post_id,
    20762076                        'comment_approved' => '1',
    20772077                        'comment_parent' => $c1,
    20782078                ) );
    20792079
    2080                 $c5 = self::$factory->comment->create( array(
     2080                $c5 = self::factory()->comment->create( array(
    20812081                        'comment_post_ID' => $this->post_id,
    20822082                        'comment_approved' => '1',
    20832083                ) );
    20842084
    2085                 self::$factory->comment->create( array(
     2085                self::factory()->comment->create( array(
    20862086                        'comment_post_ID' => $this->post_id,
    20872087                        'comment_approved' => '1',
    20882088                        'comment_parent' => $c5,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    21172117        public function test_update_comment_post_cache_should_be_disabled_by_default() {
    21182118                global $wpdb;
    21192119
    2120                 $p = self::$factory->post->create();
    2121                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     2120                $p = self::factory()->post->create();
     2121                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    21222122
    21232123                $q = new WP_Comment_Query( array(
    21242124                        'post_ID' => $p,
    class Tests_Comment_Query extends WP_UnitTestCase { 
    21352135        public function test_should_respect_update_comment_post_cache_true() {
    21362136                global $wpdb;
    21372137
    2138                 $p = self::$factory->post->create();
    2139                 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) );
     2138                $p = self::factory()->post->create();
     2139                $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) );
    21402140
    21412141                $q = new WP_Comment_Query( array(
    21422142                        'post_ID' => $p,
  • tests/phpunit/tests/comment/slashes.php

    diff --git tests/phpunit/tests/comment/slashes.php tests/phpunit/tests/comment/slashes.php
    index 01b4e99..6a87ab5 100644
    class Tests_Comment_Slashes extends WP_UnitTestCase { 
    99        function setUp() {
    1010                parent::setUp();
    1111                // we need an admin user to bypass comment flood protection
    12                 $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     12                $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    1313                $this->old_current_user = get_current_user_id();
    1414                wp_set_current_user( $this->author_id );
    1515
    class Tests_Comment_Slashes extends WP_UnitTestCase { 
    3434         *
    3535         */
    3636        function test_wp_new_comment() {
    37                 $post_id = self::$factory->post->create();
     37                $post_id = self::factory()->post->create();
    3838
    3939                // not testing comment_author_email or comment_author_url
    4040                // as slashes are not permitted in that data
    class Tests_Comment_Slashes extends WP_UnitTestCase { 
    7474         *
    7575         */
    7676        function test_edit_comment() {
    77                 $post_id = self::$factory->post->create();
    78                 $comment_id = self::$factory->comment->create(array(
     77                $post_id = self::factory()->post->create();
     78                $comment_id = self::factory()->comment->create(array(
    7979                        'comment_post_ID' => $post_id
    8080                ));
    8181
    class Tests_Comment_Slashes extends WP_UnitTestCase { 
    117117         *
    118118         */
    119119        function test_wp_insert_comment() {
    120                 $post_id = self::$factory->post->create();
     120                $post_id = self::factory()->post->create();
    121121
    122122                $comment_id = wp_insert_comment(array(
    123123                        'comment_post_ID' => $post_id,
    class Tests_Comment_Slashes extends WP_UnitTestCase { 
    145145         *
    146146         */
    147147        function test_wp_update_comment() {
    148                 $post_id = self::$factory->post->create();
    149                 $comment_id = self::$factory->comment->create(array(
     148                $post_id = self::factory()->post->create();
     149                $comment_id = self::factory()->comment->create(array(
    150150                        'comment_post_ID' => $post_id
    151151                ));
    152152
  • tests/phpunit/tests/comment/template.php

    diff --git tests/phpunit/tests/comment/template.php tests/phpunit/tests/comment/template.php
    index 8556cb0..00fd2b8 100644
     
    55class Tests_Comment_Template extends WP_UnitTestCase {
    66
    77        function test_get_comments_number() {
    8                 $post_id = self::$factory->post->create();
     8                $post_id = self::factory()->post->create();
    99
    1010                $this->assertEquals( 0, get_comments_number( 0 ) );
    1111                $this->assertEquals( 0, get_comments_number( $post_id ) );
    1212                $this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) );
    1313
    14                 self::$factory->comment->create_post_comments( $post_id, 12 );
     14                self::factory()->comment->create_post_comments( $post_id, 12 );
    1515
    1616                $this->assertEquals( 12, get_comments_number( $post_id ) );
    1717                $this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) );
    1818        }
    1919
    2020        function test_get_comments_number_without_arg() {
    21                 $post_id = self::$factory->post->create();
     21                $post_id = self::factory()->post->create();
    2222                $permalink = get_permalink( $post_id );
    2323                $this->go_to( $permalink );
    2424
    2525                $this->assertEquals( 0, get_comments_number() );
    2626
    27                 self::$factory->comment->create_post_comments( $post_id, 12 );
     27                self::factory()->comment->create_post_comments( $post_id, 12 );
    2828                $this->go_to( $permalink );
    2929
    3030                $this->assertEquals( 12, get_comments_number() );
  • tests/phpunit/tests/comment/walker.php

    diff --git tests/phpunit/tests/comment/walker.php tests/phpunit/tests/comment/walker.php
    index 8dd2607..fcd4f69 100644
    class Tests_Comment_Walker extends WP_UnitTestCase { 
    88        function setUp() {
    99                parent::setUp();
    1010
    11                 $this->post_id = self::$factory->post->create();
     11                $this->post_id = self::factory()->post->create();
    1212        }
    1313
    1414        /**
    1515         * @ticket 14041
    1616         */
    1717        function test_has_children() {
    18                 $comment_parent = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    19                 $comment_child  = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) );
     18                $comment_parent = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     19                $comment_child  = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) );
    2020                $comment_parent = get_comment( $comment_parent );
    2121                $comment_child  = get_comment( $comment_child  );
    2222
  • tests/phpunit/tests/comment/wpCountComments.php

    diff --git tests/phpunit/tests/comment/wpCountComments.php tests/phpunit/tests/comment/wpCountComments.php
    index b618fbe..4165d36 100644
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    1515        }
    1616
    1717        public function test_wp_count_comments_approved() {
    18                 self::$factory->comment->create( array(
     18                self::factory()->comment->create( array(
    1919                        'comment_approved' => 1
    2020                ) );
    2121
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    3131        }
    3232
    3333        public function test_wp_count_comments_awaiting() {
    34                 self::$factory->comment->create( array(
     34                self::factory()->comment->create( array(
    3535                        'comment_approved' => 0
    3636                ) );
    3737
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    4747        }
    4848
    4949        public function test_wp_count_comments_spam() {
    50                 self::$factory->comment->create( array(
     50                self::factory()->comment->create( array(
    5151                        'comment_approved' => 'spam'
    5252                ) );
    5353
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    6363        }
    6464
    6565        public function test_wp_count_comments_trash() {
    66                 self::$factory->comment->create( array(
     66                self::factory()->comment->create( array(
    6767                        'comment_approved' => 'trash'
    6868                ) );
    6969
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    7979        }
    8080
    8181        public function test_wp_count_comments_post_trashed() {
    82                 self::$factory->comment->create( array(
     82                self::factory()->comment->create( array(
    8383                        'comment_approved' => 'post-trashed'
    8484                ) );
    8585
    class Tests_WP_Count_Comments extends WP_UnitTestCase { 
    9595        }
    9696
    9797        public function test_wp_count_comments_cache() {
    98                 $post_id = self::$factory->post->create( array(
     98                $post_id = self::factory()->post->create( array(
    9999                        'post_status' => 'publish'
    100100                ) );
    101                 $comment_id = self::$factory->comment->create( array(
     101                $comment_id = self::factory()->comment->create( array(
    102102                        'comment_approved' => '1',
    103103                        'comment_post_ID' => $post_id
    104104                ) );
  • tests/phpunit/tests/customize/manager.php

    diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
    index ec9e2b0..b9e7f31 100644
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    251251         * @see WP_Customize_Manager::set_return_url()
    252252         */
    253253        function test_return_url() {
    254                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'author' ) ) );
     254                wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) );
    255255                $this->assertEquals( get_admin_url(), $this->manager->get_return_url() );
    256256
    257                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     257                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    258258                $this->assertTrue( current_user_can( 'edit_theme_options' ) );
    259259                $this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() );
    260260
    class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    301301         * @see WP_Customize_Manager::customize_pane_settings()
    302302         */
    303303        function test_customize_pane_settings() {
    304                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     304                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    305305                $this->manager->register_controls();
    306306                $this->manager->prepare_controls();
    307307                $autofocus = array( 'control' => 'blogname' );
  • tests/phpunit/tests/customize/nav-menu-item-setting.php

    diff --git tests/phpunit/tests/customize/nav-menu-item-setting.php tests/phpunit/tests/customize/nav-menu-item-setting.php
    index fab713e..ad2e7d2 100644
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    2121        function setUp() {
    2222                parent::setUp();
    2323                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    24                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     24                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2525
    2626                global $wp_customize;
    2727                $this->wp_customize = new WP_Customize_Manager();
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    149149        function test_value_type_post_type() {
    150150                do_action( 'customize_register', $this->wp_customize );
    151151
    152                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     152                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    153153
    154154                $menu_id = wp_create_nav_menu( 'Menu' );
    155155                $item_title = 'Greetings';
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    192192        function test_value_type_taxonomy() {
    193193                do_action( 'customize_register', $this->wp_customize );
    194194
    195                 $tax_id = self::$factory->category->create( array( 'name' => 'Salutations' ) );
     195                $tax_id = self::factory()->category->create( array( 'name' => 'Salutations' ) );
    196196
    197197                $menu_id = wp_create_nav_menu( 'Menu' );
    198198                $item_title = 'Greetings';
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    270270                $value = $menu->value();
    271271                $this->assertEquals( $post_value, $value );
    272272
    273                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     273                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    274274                $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    275275                        'menu-item-type' => 'post_type',
    276276                        'menu-item-object' => 'post',
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    296296        function test_preview_updated() {
    297297                do_action( 'customize_register', $this->wp_customize );
    298298
    299                 $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
    300                 $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) );
     299                $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
     300                $second_post_id = self::factory()->post->create( array( 'post_title' => 'Hola Muno' ) );
    301301
    302302                $primary_menu_id = wp_create_nav_menu( 'Primary' );
    303303                $secondary_menu_id = wp_create_nav_menu( 'Secondary' );
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    348348                do_action( 'customize_register', $this->wp_customize );
    349349
    350350                $menu_id = wp_create_nav_menu( 'Primary' );
    351                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     351                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    352352                $item_ids = array();
    353353                for ( $i = 0; $i < 5; $i += 1 ) {
    354354                        $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    403403                do_action( 'customize_register', $this->wp_customize );
    404404
    405405                $menu_id = wp_create_nav_menu( 'Primary' );
    406                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     406                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    407407                $item_ids = array();
    408408                for ( $i = 0; $i < 5; $i += 1 ) {
    409409                        $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    488488        function test_save_updated() {
    489489                do_action( 'customize_register', $this->wp_customize );
    490490
    491                 $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
    492                 $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) );
     491                $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
     492                $second_post_id = self::factory()->post->create( array( 'post_title' => 'Hola Muno' ) );
    493493
    494494                $primary_menu_id = wp_create_nav_menu( 'Primary' );
    495495                $secondary_menu_id = wp_create_nav_menu( 'Secondary' );
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    554554                do_action( 'customize_register', $this->wp_customize );
    555555
    556556                $menu_id = wp_create_nav_menu( 'Primary' );
    557                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     557                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    558558                $item_ids = array();
    559559                for ( $i = 0; $i < 5; $i += 1 ) {
    560560                        $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 
    623623                do_action( 'customize_register', $this->wp_customize );
    624624
    625625                $menu_id = wp_create_nav_menu( 'Primary' );
    626                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     626                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    627627                $item_ids = array();
    628628                for ( $i = 0; $i < 5; $i += 1 ) {
    629629                        $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
  • tests/phpunit/tests/customize/nav-menu-setting.php

    diff --git tests/phpunit/tests/customize/nav-menu-setting.php tests/phpunit/tests/customize/nav-menu-setting.php
    index 7f4616c..a3438c9 100644
    class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { 
    2222        function setUp() {
    2323                parent::setUp();
    2424                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    25                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     25                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2626
    2727                global $wp_customize;
    2828                $this->wp_customize = new WP_Customize_Manager();
  • tests/phpunit/tests/customize/nav-menus.php

    diff --git tests/phpunit/tests/customize/nav-menus.php tests/phpunit/tests/customize/nav-menus.php
    index 5add129..dd620c3 100644
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    2222        function setUp() {
    2323                parent::setUp();
    2424                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    25                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     25                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2626                global $wp_customize;
    2727                $this->wp_customize = new WP_Customize_Manager();
    2828                $wp_customize = $this->wp_customize;
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    124124                );
    125125
    126126                // Create pages.
    127                 self::$factory->post->create_many( 12, array( 'post_type' => 'page' ) );
     127                self::factory()->post->create_many( 12, array( 'post_type' => 'page' ) );
    128128
    129129                // Home is included in menu items when page is zero.
    130130                $items = $menus->load_available_items_query( 'post_type', 'page', 0 );
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    145145                $menus = new WP_Customize_Nav_Menus( $this->wp_customize );
    146146
    147147                // Create page.
    148                 $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
     148                $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) );
    149149
    150150                // Create pages.
    151                 self::$factory->post->create_many( 10 );
     151                self::factory()->post->create_many( 10 );
    152152
    153153                // Expected menu item array.
    154154                $expected = array(
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    175175                $menus = new WP_Customize_Nav_Menus( $this->wp_customize );
    176176
    177177                // Create page.
    178                 $page_id = self::$factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
     178                $page_id = self::factory()->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) );
    179179
    180180                // Expected menu item array.
    181181                $expected = array(
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    201201                $menus = new WP_Customize_Nav_Menus( $this->wp_customize );
    202202
    203203                // Create post.
    204                 $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) );
     204                $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) );
    205205
    206206                // Expected menu item array.
    207207                $expected = array(
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    227227                $menus = new WP_Customize_Nav_Menus( $this->wp_customize );
    228228
    229229                // Create term.
    230                 $term_id = self::$factory->category->create( array( 'name' => 'Term Title' ) );
     230                $term_id = self::factory()->category->create( array( 'name' => 'Term Title' ) );
    231231
    232232                // Expected menu item array.
    233233                $expected = array(
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    279279
    280280                // Create posts
    281281                $post_ids = array();
    282                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) );
    283                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Some Other Title' ) );
     282                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Search & Test' ) );
     283                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Some Other Title' ) );
    284284
    285285                // Create terms
    286286                $term_ids = array();
    287                 $term_ids[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) );
    288                 $term_ids[] = self::$factory->category->create( array( 'name' => 'Cats Drool' ) );
     287                $term_ids[] = self::factory()->category->create( array( 'name' => 'Dogs Are Cool' ) );
     288                $term_ids[] = self::factory()->category->create( array( 'name' => 'Cats Drool' ) );
    289289
    290290                // Test empty results
    291291                $expected = array();
    class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { 
    386386        function test_customize_register() {
    387387                do_action( 'customize_register', $this->wp_customize );
    388388                $menu_id = wp_create_nav_menu( 'Primary' );
    389                 $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) );
     389                $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
    390390                $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
    391391                        'menu-item-type'      => 'post_type',
    392392                        'menu-item-object'    => 'post',
  • tests/phpunit/tests/customize/panel.php

    diff --git tests/phpunit/tests/customize/panel.php tests/phpunit/tests/customize/panel.php
    index f1b62cb..13359a1 100644
    class Tests_WP_Customize_Panel extends WP_UnitTestCase { 
    128128         * @see WP_Customize_Panel::check_capabilities()
    129129         */
    130130        function test_check_capabilities() {
    131                 $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     131                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    132132                wp_set_current_user( $user_id );
    133133
    134134                $panel = new WP_Customize_Panel( $this->manager, 'foo' );
    class Tests_WP_Customize_Panel extends WP_UnitTestCase { 
    154154         * @see WP_Customize_Panel::maybe_render()
    155155         */
    156156        function test_maybe_render() {
    157                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     157                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    158158                $panel = new WP_Customize_Panel( $this->manager, 'bar' );
    159159                $customize_render_panel_count = did_action( 'customize_render_panel' );
    160160                add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) );
    class Tests_WP_Customize_Panel extends WP_UnitTestCase { 
    179179         * @see WP_Customize_Panel::print_template()
    180180         */
    181181        function test_print_templates_standard() {
    182                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     182                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    183183
    184184                $panel = new WP_Customize_Panel( $this->manager, 'baz' );
    185185                ob_start();
    class Tests_WP_Customize_Panel extends WP_UnitTestCase { 
    197197         * @see WP_Customize_Panel::print_template()
    198198         */
    199199        function test_print_templates_custom() {
    200                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     200                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    201201
    202202                $panel = new Custom_Panel_Test( $this->manager, 'baz' );
    203203                ob_start();
  • tests/phpunit/tests/customize/section.php

    diff --git tests/phpunit/tests/customize/section.php tests/phpunit/tests/customize/section.php
    index 2ed81b6..dad67ed 100644
    class Tests_WP_Customize_Section extends WP_UnitTestCase { 
    135135         * @see WP_Customize_Section::check_capabilities()
    136136         */
    137137        function test_check_capabilities() {
    138                 $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     138                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    139139                wp_set_current_user( $user_id );
    140140
    141141                $section = new WP_Customize_Section( $this->manager, 'foo' );
    class Tests_WP_Customize_Section extends WP_UnitTestCase { 
    161161         * @see WP_Customize_Section::maybe_render()
    162162         */
    163163        function test_maybe_render() {
    164                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     164                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    165165                $section = new WP_Customize_Section( $this->manager, 'bar' );
    166166                $customize_render_section_count = did_action( 'customize_render_section' );
    167167                add_action( 'customize_render_section', array( $this, 'action_customize_render_section_test' ) );
    class Tests_WP_Customize_Section extends WP_UnitTestCase { 
    186186         * @see WP_Customize_Section::print_template()
    187187         */
    188188        function test_print_templates_standard() {
    189                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     189                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    190190
    191191                $section = new WP_Customize_Section( $this->manager, 'baz' );
    192192                ob_start();
    class Tests_WP_Customize_Section extends WP_UnitTestCase { 
    201201         * @see WP_Customize_Section::print_template()
    202202         */
    203203        function test_print_templates_custom() {
    204                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     204                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    205205
    206206                $section = new Custom_Section_Test( $this->manager, 'baz' );
    207207                ob_start();
  • tests/phpunit/tests/customize/setting.php

    diff --git tests/phpunit/tests/customize/setting.php tests/phpunit/tests/customize/setting.php
    index 803f090..296554b 100644
    class Tests_WP_Customize_Setting extends WP_UnitTestCase { 
    394394                $this->assertTrue( 0 === did_action( 'customize_save_foo' ) );
    395395
    396396                // Satisfy all requirements for save to happen.
    397                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     397                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    398398                $this->assertTrue( false !== $setting->save() );
    399399                $this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
    400400                $this->assertTrue( 1 === did_action( 'customize_save_foo' ) );
    class Tests_WP_Customize_Setting extends WP_UnitTestCase { 
    465465                $setting->preview();
    466466                $this->assertTrue( $setting->is_current_blog_previewed() );
    467467
    468                 $blog_id = self::$factory->blog->create();
     468                $blog_id = self::factory()->blog->create();
    469469                switch_to_blog( $blog_id );
    470470                $this->assertFalse( $setting->is_current_blog_previewed() );
    471471                $this->assertNotEquals( $post_value, $setting->value() );
  • tests/phpunit/tests/customize/widgets.php

    diff --git tests/phpunit/tests/customize/widgets.php tests/phpunit/tests/customize/widgets.php
    index 6dd47d0..6584341 100644
    class Tests_WP_Customize_Widgets extends WP_UnitTestCase { 
    3838
    3939                remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway
    4040
    41                 $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     41                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    4242                wp_set_current_user( $user_id );
    4343
    4444                $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
  • tests/phpunit/tests/date/query.php

    diff --git tests/phpunit/tests/date/query.php tests/phpunit/tests/date/query.php
    index 7ce8165..cc848be 100644
    class Tests_WP_Date_Query extends WP_UnitTestCase { 
    975975         * @ticket 31001
    976976         */
    977977        public function test_validate_date_values_should_process_array_value_for_year() {
    978                 $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
    979                 $p2 = self::$factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) );
     978                $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
     979                $p2 = self::factory()->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) );
    980980
    981981                $q = new WP_Query( array(
    982982                        'date_query' => array(
    class Tests_WP_Date_Query extends WP_UnitTestCase { 
    995995         * @ticket 31001
    996996         */
    997997        public function test_validate_date_values_should_process_array_value_for_day() {
    998                 $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
    999                 $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
     998                $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
     999                $p2 = self::factory()->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
    10001000
    10011001                $q = new WP_Query( array(
    10021002                        'date_query' => array(
    class Tests_WP_Date_Query extends WP_UnitTestCase { 
    10161016         * @expectedIncorrectUsage WP_Date_Query
    10171017         */
    10181018        public function test_validate_date_values_should_process_array_value_for_day_when_values_are_invalid() {
    1019                 $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
    1020                 $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
     1019                $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) );
     1020                $p2 = self::factory()->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) );
    10211021
    10221022                $q = new WP_Query( array(
    10231023                        'date_query' => array(
  • tests/phpunit/tests/db.php

    diff --git tests/phpunit/tests/db.php tests/phpunit/tests/db.php
    index fd3517d..74036a2 100644
    class Tests_DB extends WP_UnitTestCase { 
    509509                        $this->markTestSkipped( 'procedure could not be created (missing privileges?)' );
    510510                }
    511511
    512                 $post_id = self::$factory->post->create();
     512                $post_id = self::factory()->post->create();
    513513
    514514                $this->assertNotEmpty( $wpdb->get_results( 'CALL `test_mysqli_flush_sync_procedure`' ) );
    515515                $this->assertNotEmpty( $wpdb->get_results( "SELECT ID FROM `{$wpdb->posts}` LIMIT 1" ) );
  • tests/phpunit/tests/formatting/SanitizePost.php

    diff --git tests/phpunit/tests/formatting/SanitizePost.php tests/phpunit/tests/formatting/SanitizePost.php
    index 691c082..c741214 100644
    class Tests_Formatting_SanitizePost extends WP_UnitTestCase { 
    99         * @ticket 22324
    1010         */
    1111        function test_int_fields() {
    12                 $post = self::$factory->post->create_and_get();
     12                $post = self::factory()->post->create_and_get();
    1313                $int_fields = array(
    1414                        'ID'            => 'integer',
    1515                        'post_parent'   => 'integer',
  • tests/phpunit/tests/formatting/WpTrimExcerpt.php

    diff --git tests/phpunit/tests/formatting/WpTrimExcerpt.php tests/phpunit/tests/formatting/WpTrimExcerpt.php
    index 8aafa8e..da508c7 100644
    class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { 
    99         * @ticket 25349
    1010         */
    1111        public function test_secondary_loop_respect_more() {
    12                 $post1 = self::$factory->post->create( array(
     12                $post1 = self::factory()->post->create( array(
    1313                        'post_content' => 'Post 1 Page 1<!--more-->Post 1 Page 2',
    1414                ) );
    15                 $post2 = self::$factory->post->create( array(
     15                $post2 = self::factory()->post->create( array(
    1616                        'post_content' => 'Post 2 Page 1<!--more-->Post 2 Page 2',
    1717                ) );
    1818
    class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { 
    3434         * @ticket 25349
    3535         */
    3636        public function test_secondary_loop_respect_nextpage() {
    37                 $post1 = self::$factory->post->create( array(
     37                $post1 = self::factory()->post->create( array(
    3838                        'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2',
    3939                ) );
    40                 $post2 = self::$factory->post->create( array(
     40                $post2 = self::factory()->post->create( array(
    4141                        'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2',
    4242                ) );
    4343
  • tests/phpunit/tests/functions.php

    diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
    index d44f470..1119770 100644
    class Tests_Functions extends WP_UnitTestCase { 
    689689                $actual = ob_get_clean();
    690690                $this->assertEquals( '', $actual );
    691691
    692                 $GLOBALS['post']        = self::$factory->post->create_and_get( array(
     692                $GLOBALS['post']        = self::factory()->post->create_and_get( array(
    693693                        'post_date' => '2015-09-16 08:00:00'
    694694                ) );
    695695
  • tests/phpunit/tests/functions/getArchives.php

    diff --git tests/phpunit/tests/functions/getArchives.php tests/phpunit/tests/functions/getArchives.php
    index 393808d..2d70387 100644
    EOF; 
    8787        }
    8888
    8989        function test_wp_get_archives_order() {
    90                 self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) );
     90                self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) );
    9191
    9292                $date_full = date( 'F Y' );
    9393                $oct_url = get_month_link( 2012, 10 );
    EOF; 
    110110        function test_wp_get_archives_post_type() {
    111111                register_post_type( 'taco', array( 'public' => true ) );
    112112
    113                 self::$factory->post->create( array(
     113                self::factory()->post->create( array(
    114114                        'post_type' => 'taco',
    115115                        'post_author' => '1',
    116116                        'post_date' => '2014-10-23 19:34:42'
  • tests/phpunit/tests/general/archives.php

    diff --git tests/phpunit/tests/general/archives.php tests/phpunit/tests/general/archives.php
    index e34e6c1..3e10f2a 100644
    class Tests_General_Archives extends WP_UnitTestCase { 
    1616        function test_get_archives_cache() {
    1717                global $wpdb;
    1818
    19                 self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) );
     19                self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) );
    2020                wp_cache_delete( 'last_changed', 'posts' );
    2121                $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
    2222
  • tests/phpunit/tests/includes/factory.php

    diff --git tests/phpunit/tests/includes/factory.php tests/phpunit/tests/includes/factory.php
    index e7c6929..3eef943 100644
    class TestFactoryFor extends WP_UnitTestCase { 
    3434         */
    3535        public function test_term_factory_create_and_get_should_return_term_object() {
    3636                register_taxonomy( 'wptests_tax', 'post' );
    37                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
     37                $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
    3838                $this->assertInternalType( 'object', $term );
    3939                $this->assertNotEmpty( $term->term_id );
    4040        }
  • tests/phpunit/tests/link.php

    diff --git tests/phpunit/tests/link.php tests/phpunit/tests/link.php
    index 08275d1..272b4cd 100644
    class Tests_Link extends WP_UnitTestCase { 
    3333        }
    3434
    3535        function test_wp_get_shortlink() {
    36                 $post_id = self::$factory->post->create();
    37                 $post_id2 = self::$factory->post->create();
     36                $post_id = self::factory()->post->create();
     37                $post_id2 = self::factory()->post->create();
    3838
    3939                // Basic case
    4040                $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) );
    class Tests_Link extends WP_UnitTestCase { 
    7777        }
    7878
    7979        function test_wp_get_shortlink_with_page() {
    80                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     80                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    8181
    8282                // Basic case
    8383                // Don't test against get_permalink() since it uses ?page_id= for pages.
    class Tests_Link extends WP_UnitTestCase { 
    9292         * @ticket 26871
    9393         */
    9494        function test_wp_get_shortlink_with_home_page() {
    95                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     95                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    9696                update_option( 'show_on_front', 'page' );
    9797                update_option( 'page_on_front', $post_id );
    9898
    class Tests_Link extends WP_UnitTestCase { 
    108108         */
    109109        function test_get_adjacent_post() {
    110110                // Need some sample posts to test adjacency
    111                 $post_one = self::$factory->post->create_and_get( array(
     111                $post_one = self::factory()->post->create_and_get( array(
    112112                        'post_title' => 'First',
    113113                        'post_date' => '2012-01-01 12:00:00'
    114114                ) );
    115115
    116                 $post_two = self::$factory->post->create_and_get( array(
     116                $post_two = self::factory()->post->create_and_get( array(
    117117                        'post_title' => 'Second',
    118118                        'post_date' => '2012-02-01 12:00:00'
    119119                ) );
    120120
    121                 $post_three = self::$factory->post->create_and_get( array(
     121                $post_three = self::factory()->post->create_and_get( array(
    122122                        'post_title' => 'Third',
    123123                        'post_date' => '2012-03-01 12:00:00'
    124124                ) );
    125125
    126                 $post_four = self::$factory->post->create_and_get( array(
     126                $post_four = self::factory()->post->create_and_get( array(
    127127                        'post_title' => 'Fourth',
    128128                        'post_date' => '2012-04-01 12:00:00'
    129129                ) );
    class Tests_Link extends WP_UnitTestCase { 
    183183                global $wpdb;
    184184                $wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) );
    185185
    186                 $include = self::$factory->term->create( array(
     186                $include = self::factory()->term->create( array(
    187187                        'taxonomy' => 'category',
    188188                        'name' => 'Include',
    189189                ) );
    190                 $exclude = self::$factory->category->create();
     190                $exclude = self::factory()->category->create();
    191191
    192                 $one = self::$factory->post->create_and_get( array(
     192                $one = self::factory()->post->create_and_get( array(
    193193                        'post_date' => '2012-01-01 12:00:00',
    194194                        'post_category' => array( $include, $exclude ),
    195195                ) );
    196196
    197                 $two = self::$factory->post->create_and_get( array(
     197                $two = self::factory()->post->create_and_get( array(
    198198                        'post_date' => '2012-01-02 12:00:00',
    199199                        'post_category' => array(),
    200200                ) );
    201201
    202                 $three = self::$factory->post->create_and_get( array(
     202                $three = self::factory()->post->create_and_get( array(
    203203                        'post_date' => '2012-01-03 12:00:00',
    204204                        'post_category' => array( $include, $exclude ),
    205205                ) );
    206206
    207                 $four = self::$factory->post->create_and_get( array(
     207                $four = self::factory()->post->create_and_get( array(
    208208                        'post_date' => '2012-01-04 12:00:00',
    209209                        'post_category' => array( $include ),
    210210                ) );
    211211
    212                 $five = self::$factory->post->create_and_get( array(
     212                $five = self::factory()->post->create_and_get( array(
    213213                        'post_date' => '2012-01-05 12:00:00',
    214214                        'post_category' => array( $include, $exclude ),
    215215                ) );
    class Tests_Link extends WP_UnitTestCase { 
    249249        public function test_get_adjacent_post_excluded_terms() {
    250250                register_taxonomy( 'wptests_tax', 'post' );
    251251
    252                 $t = self::$factory->term->create( array(
     252                $t = self::factory()->term->create( array(
    253253                        'taxonomy' => 'wptests_tax',
    254254                ) );
    255255
    256                 $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
    257                 $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
    258                 $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
     256                $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
     257                $p2 = self::factory()->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
     258                $p3 = self::factory()->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
    259259
    260260                wp_set_post_terms( $p2, array( $t ), 'wptests_tax' );
    261261
    class Tests_Link extends WP_UnitTestCase { 
    281281        public function test_get_adjacent_post_excluded_terms_should_not_require_posts_to_have_terms_in_any_taxonomy() {
    282282                register_taxonomy( 'wptests_tax', 'post' );
    283283
    284                 $t = self::$factory->term->create( array(
     284                $t = self::factory()->term->create( array(
    285285                        'taxonomy' => 'wptests_tax',
    286286                ) );
    287287
    288                 $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
    289                 $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
    290                 $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
     288                $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) );
     289                $p2 = self::factory()->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) );
     290                $p3 = self::factory()->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) );
    291291
    292292                wp_set_post_terms( $p2, array( $t ), 'wptests_tax' );
    293293
    class Tests_Link extends WP_UnitTestCase { 
    348348
    349349                flush_rewrite_rules();
    350350
    351                 $p = self::$factory->post->create( array(
     351                $p = self::factory()->post->create( array(
    352352                        'post_status' => 'publish',
    353353                        'post_date'   => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
    354354                ) );
    class Tests_Link extends WP_UnitTestCase { 
    368368
    369369                flush_rewrite_rules();
    370370
    371                 $p = self::$factory->post->create( array(
     371                $p = self::factory()->post->create( array(
    372372                        'post_status' => 'future',
    373373                        'post_type'   => 'wptests_pt',
    374374                        'post_date'   => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) )
    class Tests_Link extends WP_UnitTestCase { 
    388388        public function test_unattached_attachment_has_a_pretty_permalink() {
    389389                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    390390
    391                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
     391                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array(
    392392                        'post_mime_type' => 'image/jpeg',
    393393                        'post_type' => 'attachment',
    394394                        'post_title' => 'An Attachment!',
    class Tests_Link extends WP_UnitTestCase { 
    412412
    413413                flush_rewrite_rules();
    414414
    415                 $post_id = self::$factory->post->create( array( 'post_type' => 'not_a_post_type' ) );
     415                $post_id = self::factory()->post->create( array( 'post_type' => 'not_a_post_type' ) );
    416416
    417                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
     417                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    418418                        'post_mime_type' => 'image/jpeg',
    419419                        'post_type' => 'attachment',
    420420                        'post_title' => 'An Attachment!',
  • tests/phpunit/tests/link/getAdjacentPostLink.php

    diff --git tests/phpunit/tests/link/getAdjacentPostLink.php tests/phpunit/tests/link/getAdjacentPostLink.php
    index 08064e1..68c511d 100644
    class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase { 
    1010
    1111        public function setUp(){
    1212                parent::setUp();
    13                 $this->cat_id = self::$factory->category->create( array( 'name' => 'other' ) );
     13                $this->cat_id = self::factory()->category->create( array( 'name' => 'other' ) );
    1414                $this->post_ids = array();
    15                 $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );
    16                 $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );
    17                 $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );
    18                 $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );
    19                 $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );
     15                $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );
     16                $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );
     17                $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );
     18                $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );
     19                $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );
    2020
    2121                //set current post (has 2 on each end)
    2222                global $GLOBALS;
  • tests/phpunit/tests/link/getNextCommentsLink.php

    diff --git tests/phpunit/tests/link/getNextCommentsLink.php tests/phpunit/tests/link/getNextCommentsLink.php
    index 8f148db..204b205 100644
     
    88class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase {
    99
    1010        public function test_page_should_respect_value_of_cpage_query_var() {
    11                 $p = self::$factory->post->create();
     11                $p = self::factory()->post->create();
    1212                $this->go_to( get_permalink( $p ) );
    1313
    1414                $cpage = get_query_var( 'cpage' );
    class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase { 
    2525         * @ticket 20319
    2626         */
    2727        public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
    28                 $p = self::$factory->post->create();
     28                $p = self::factory()->post->create();
    2929                $this->go_to( get_permalink( $p ) );
    3030
    3131                $cpage = get_query_var( 'cpage' );
  • tests/phpunit/tests/link/getPostCommentsFeedLink.php

    diff --git tests/phpunit/tests/link/getPostCommentsFeedLink.php tests/phpunit/tests/link/getPostCommentsFeedLink.php
    index e3972fc..5e1eddc 100644
     
    55class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
    66
    77        public function test_post_link() {
    8                 $post_id = self::$factory->post->create();
     8                $post_id = self::factory()->post->create();
    99
    1010                $link = get_post_comments_feed_link( $post_id );
    1111                $expected = add_query_arg( array(
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    1919        public function test_post_pretty_link() {
    2020                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    2121
    22                 $post_id = self::$factory->post->create();
     22                $post_id = self::factory()->post->create();
    2323
    2424                $link = get_post_comments_feed_link( $post_id );
    2525                $expected = get_permalink( $post_id ) . 'feed/';
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    2828        }
    2929
    3030        public function test_attachment_link() {
    31                 $post_id = self::$factory->post->create();
    32                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
     31                $post_id = self::factory()->post->create();
     32                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    3333                        'post_mime_type' => 'image/jpeg',
    3434                        'post_type' => 'attachment'
    3535                ) );
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    4646        public function test_attachment_pretty_link() {
    4747                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    4848
    49                 $post_id = self::$factory->post->create( array(
     49                $post_id = self::factory()->post->create( array(
    5050                        'post_status' => 'publish'
    5151                ) );
    52                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
     52                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    5353                        'post_mime_type' => 'image/jpeg',
    5454                        'post_type' => 'attachment',
    5555                        'post_title' => 'Burrito'
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    6666        public function test_attachment_no_name_pretty_link() {
    6767                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    6868
    69                 $post_id = self::$factory->post->create();
    70                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array(
     69                $post_id = self::factory()->post->create();
     70                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array(
    7171                        'post_mime_type' => 'image/jpeg',
    7272                        'post_type' => 'attachment'
    7373                ) );
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    7979        }
    8080
    8181        public function test_unattached_link() {
    82                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
     82                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array(
    8383                        'post_mime_type' => 'image/jpeg',
    8484                        'post_type' => 'attachment'
    8585                ) );
    class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { 
    9696        public function test_unattached_pretty_link() {
    9797                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    9898
    99                 $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
     99                $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array(
    100100                        'post_mime_type' => 'image/jpeg',
    101101                        'post_type' => 'attachment'
    102102                ) );
  • tests/phpunit/tests/link/getPreviousCommentsLink.php

    diff --git tests/phpunit/tests/link/getPreviousCommentsLink.php tests/phpunit/tests/link/getPreviousCommentsLink.php
    index ea9ad6c..ff4c088 100644
     
    88class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase {
    99
    1010        public function test_page_should_respect_value_of_cpage_query_var() {
    11                 $p = self::$factory->post->create();
     11                $p = self::factory()->post->create();
    1212                $this->go_to( get_permalink( $p ) );
    1313
    1414                $cpage = get_query_var( 'cpage' );
    class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { 
    2222        }
    2323
    2424        public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
    25                 $p = self::$factory->post->create();
     25                $p = self::factory()->post->create();
    2626                $this->go_to( get_permalink( $p ) );
    2727
    2828                $cpage = get_query_var( 'cpage' );
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index b68a537..24fbfd4 100644
    EOF; 
    236236         * @ticket 22960
    237237         */
    238238        function test_get_attached_images() {
    239                 $post_id = self::$factory->post->create();
    240                 $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array(
     239                $post_id = self::factory()->post->create();
     240                $attachment_id = self::factory()->attachment->create_object( $this->img_name, $post_id, array(
    241241                        'post_mime_type' => 'image/jpeg',
    242242                        'post_type' => 'attachment'
    243243                ) );
    EOF; 
    253253                $ids1 = array();
    254254                $ids1_srcs = array();
    255255                foreach ( range( 1, 3 ) as $i ) {
    256                         $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
     256                        $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array(
    257257                                'post_mime_type' => 'image/jpeg',
    258258                                'post_type' => 'attachment'
    259259                        ) );
    EOF; 
    266266                $ids2 = array();
    267267                $ids2_srcs = array();
    268268                foreach ( range( 4, 6 ) as $i ) {
    269                         $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
     269                        $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array(
    270270                                'post_mime_type' => 'image/jpeg',
    271271                                'post_type' => 'attachment'
    272272                        ) );
    EOF; 
    284284
    285285[gallery ids="$ids2_joined"]
    286286BLOB;
    287                 $post_id = self::$factory->post->create( array( 'post_content' => $blob ) );
     287                $post_id = self::factory()->post->create( array( 'post_content' => $blob ) );
    288288                $srcs = get_post_galleries_images( $post_id );
    289289                $this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) );
    290290        }
    BLOB; 
    296296                $ids1 = array();
    297297                $ids1_srcs = array();
    298298                foreach ( range( 1, 3 ) as $i ) {
    299                         $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
     299                        $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array(
    300300                                'post_mime_type' => 'image/jpeg',
    301301                                'post_type' => 'attachment'
    302302                        ) );
    BLOB; 
    309309                $ids2 = array();
    310310                $ids2_srcs = array();
    311311                foreach ( range( 4, 6 ) as $i ) {
    312                         $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array(
     312                        $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array(
    313313                                'post_mime_type' => 'image/jpeg',
    314314                                'post_type' => 'attachment'
    315315                        ) );
    BLOB; 
    327327
    328328[gallery ids="$ids2_joined"]
    329329BLOB;
    330                 $post_id = self::$factory->post->create( array( 'post_content' => $blob ) );
     330                $post_id = self::factory()->post->create( array( 'post_content' => $blob ) );
    331331                $srcs = get_post_gallery_images( $post_id );
    332332                $this->assertEquals( $srcs, $ids1_srcs );
    333333        }
    VIDEO; 
    505505         */
    506506        function test_attachment_url_to_postid() {
    507507                $image_path = '2014/11/' . $this->img_name;
    508                 $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
     508                $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array(
    509509                        'post_mime_type' => 'image/jpeg',
    510510                        'post_type'      => 'attachment',
    511511                ) );
    VIDEO; 
    516516
    517517        function test_attachment_url_to_postid_schemes() {
    518518                $image_path = '2014/11/' . $this->img_name;
    519                 $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
     519                $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array(
    520520                        'post_mime_type' => 'image/jpeg',
    521521                        'post_type'      => 'attachment',
    522522                ) );
    VIDEO; 
    530530
    531531        function test_attachment_url_to_postid_filtered() {
    532532                $image_path = '2014/11/' . $this->img_name;
    533                 $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array(
     533                $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array(
    534534                        'post_mime_type' => 'image/jpeg',
    535535                        'post_type'      => 'attachment',
    536536                ) );
    EOF; 
    704704        function test_wp_get_attachment_image_url() {
    705705                $this->assertFalse( wp_get_attachment_image_url( 0 ) );
    706706
    707                 $post_id = self::$factory->post->create();
    708                 $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array(
     707                $post_id = self::factory()->post->create();
     708                $attachment_id = self::factory()->attachment->create_object( $this->img_name, $post_id, array(
    709709                        'post_mime_type' => 'image/jpeg',
    710710                        'post_type' => 'attachment',
    711711                ) );
    EOF; 
    760760
    761761                // Make an image.
    762762                $filename = DIR_TESTDATA . '/images/test-image-large.png';
    763                 $id = self::$factory->attachment->create_upload_object( $filename );
     763                $id = self::factory()->attachment->create_upload_object( $filename );
    764764
    765765                $image = wp_get_attachment_metadata( $id );
    766766
  • tests/phpunit/tests/meta.php

    diff --git tests/phpunit/tests/meta.php tests/phpunit/tests/meta.php
    index e975d6a..0676c7e 100644
    class Tests_Meta extends WP_UnitTestCase { 
    88
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
     11                $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
    1212                $this->meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value' );
    1313                $this->delete_meta_id = add_metadata( 'user', $this->author->ID, 'delete_meta_key', 'delete_meta_value' );
    1414        }
    class Tests_Meta extends WP_UnitTestCase { 
    194194         * @ticket 16814
    195195         */
    196196        function test_meta_type_cast() {
    197                 $post_id1 = self::$factory->post->create();
     197                $post_id1 = self::factory()->post->create();
    198198                add_post_meta( $post_id1, 'num_as_longtext', 123 );
    199199                add_post_meta( $post_id1, 'num_as_longtext_desc', 10 );
    200                 $post_id2 = self::$factory->post->create();
     200                $post_id2 = self::factory()->post->create();
    201201                add_post_meta( $post_id2, 'num_as_longtext', 99 );
    202202                add_post_meta( $post_id2, 'num_as_longtext_desc', 100 );
    203203
    class Tests_Meta extends WP_UnitTestCase { 
    258258        }
    259259
    260260        function test_meta_cache_order_asc() {
    261                 $post_id = self::$factory->post->create();
     261                $post_id = self::factory()->post->create();
    262262                $colors = array( 'red', 'blue', 'yellow', 'green' );
    263263                foreach ( $colors as $color )
    264264                        add_post_meta( $post_id, 'color', $color );
  • tests/phpunit/tests/meta/slashes.php

    diff --git tests/phpunit/tests/meta/slashes.php tests/phpunit/tests/meta/slashes.php
    index 3f876d2..a5da86f 100644
     
    88class Tests_Meta_Slashes extends WP_UnitTestCase {
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
    12                 $this->post_id = self::$factory->post->create();
     11                $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
     12                $this->post_id = self::factory()->post->create();
    1313                $this->old_current_user = get_current_user_id();
    1414                wp_set_current_user( $this->author_id );
    1515
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    3232         *
    3333         */
    3434        function test_edit_post() {
    35                 $id = self::$factory->post->create();
     35                $id = self::factory()->post->create();
    3636                if ( function_exists( 'wp_add_post_meta' ) ) {
    3737                        $meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' );
    3838                        $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    108108         *
    109109         */
    110110        function test_add_post_meta() {
    111                 $id = self::$factory->post->create();
     111                $id = self::factory()->post->create();
    112112                add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
    113113                add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
    114114                add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    123123         *
    124124         */
    125125        function test_update_post_meta() {
    126                 $id = self::$factory->post->create();
     126                $id = self::factory()->post->create();
    127127                update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) );
    128128                update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) );
    129129                update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    141141                if ( !function_exists( 'wp_add_post_meta' ) ) {
    142142                        return;
    143143                }
    144                 $id = self::$factory->post->create();
     144                $id = self::factory()->post->create();
    145145                wp_add_post_meta( $id, 'slash_test_1', $this->slash_1 );
    146146                wp_add_post_meta( $id, 'slash_test_2', $this->slash_3 );
    147147                wp_add_post_meta( $id, 'slash_test_3', $this->slash_4 );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    159159                if ( !function_exists( 'wp_update_post_meta' ) ) {
    160160                        return;
    161161                }
    162                 $id = self::$factory->post->create();
     162                $id = self::factory()->post->create();
    163163                wp_update_post_meta( $id, 'slash_test_1', $this->slash_1 );
    164164                wp_update_post_meta( $id, 'slash_test_2', $this->slash_3 );
    165165                wp_update_post_meta( $id, 'slash_test_3', $this->slash_4 );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    174174         *
    175175         */
    176176        function test_add_comment_meta() {
    177                 $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     177                $id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    178178
    179179                add_comment_meta( $id, 'slash_test_1', $this->slash_1 );
    180180                add_comment_meta( $id, 'slash_test_2', $this->slash_3 );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    198198         *
    199199         */
    200200        function test_update_comment_meta() {
    201                 $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) );
     201                $id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) );
    202202
    203203                add_comment_meta( $id, 'slash_test_1', 'foo' );
    204204                add_comment_meta( $id, 'slash_test_2', 'foo' );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    226226         *
    227227         */
    228228        function test_add_user_meta() {
    229                 $id = self::$factory->user->create();
     229                $id = self::factory()->user->create();
    230230
    231231                add_user_meta( $id, 'slash_test_1', $this->slash_1 );
    232232                add_user_meta( $id, 'slash_test_2', $this->slash_3 );
    class Tests_Meta_Slashes extends WP_UnitTestCase { 
    250250         *
    251251         */
    252252        function test_update_user_meta() {
    253                 $id = self::$factory->user->create();
     253                $id = self::factory()->user->create();
    254254
    255255                add_user_meta( $id, 'slash_test_1', 'foo' );
    256256                add_user_meta( $id, 'slash_test_2', 'foo' );
  • tests/phpunit/tests/multisite/bootstrap.php

    diff --git tests/phpunit/tests/multisite/bootstrap.php tests/phpunit/tests/multisite/bootstrap.php
    index b9fb2ad..c2fabbf 100644
    class Tests_Multisite_Bootstrap extends WP_UnitTestCase { 
    4040                );
    4141
    4242                foreach ( $ids as &$id ) {
    43                         $id = self::$factory->network->create( $id );
     43                        $id = self::factory()->network->create( $id );
    4444                }
    4545                unset( $id );
    4646
    class Tests_Multisite_Bootstrap extends WP_UnitTestCase { 
    8888                );
    8989
    9090                foreach ( $ids as &$id ) {
    91                         $id = self::$factory->blog->create( $id );
     91                        $id = self::factory()->blog->create( $id );
    9292                }
    9393                unset( $id );
    9494
    class Tests_Multisite_Bootstrap extends WP_UnitTestCase { 
    169169                );
    170170
    171171                foreach ( $network_ids as &$id ) {
    172                         $id = self::$factory->network->create( $id );
     172                        $id = self::factory()->network->create( $id );
    173173                }
    174174                unset( $id );
    175175
    class Tests_Multisite_Bootstrap extends WP_UnitTestCase { 
    182182                );
    183183
    184184                foreach ( $ids as &$id ) {
    185                         $id = self::$factory->blog->create( $id );
     185                        $id = self::factory()->blog->create( $id );
    186186                }
    187187                unset( $id );
    188188
  • tests/phpunit/tests/multisite/getSpaceUsed.php

    diff --git tests/phpunit/tests/multisite/getSpaceUsed.php tests/phpunit/tests/multisite/getSpaceUsed.php
    index bd355cc..cbc5138 100644
    class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { 
    2222        }
    2323
    2424        function test_get_space_used_switched_site() {
    25                 $blog_id = self::$factory->blog->create();
     25                $blog_id = self::factory()->blog->create();
    2626                switch_to_blog( $blog_id );
    2727
    2828                // Our comparison of space relies on an initial value of 0. If a previous test has failed or if the
    class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { 
    3030                // will be polluted. We create sites until an empty one is available.
    3131                while ( 0 != get_space_used() ) {
    3232                        restore_current_blog();
    33                         $blog_id = self::$factory->blog->create();
     33                        $blog_id = self::factory()->blog->create();
    3434                        switch_to_blog( $blog_id );
    3535                }
    3636
    class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { 
    5858        function test_get_space_used_main_site() {
    5959                $space_used = get_space_used();
    6060
    61                 $blog_id = self::$factory->blog->create();
     61                $blog_id = self::factory()->blog->create();
    6262                switch_to_blog( $blog_id );
    6363
    6464                // We don't rely on an initial value of 0 for space used, but should have a clean space available
    class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { 
    6666                // existing content directories in src.
    6767                while ( 0 != get_space_used() ) {
    6868                        restore_current_blog();
    69                         $blog_id = self::$factory->blog->create();
     69                        $blog_id = self::factory()->blog->create();
    7070                        switch_to_blog( $blog_id );
    7171                }
    7272
  • tests/phpunit/tests/multisite/ms-files-rewriting.php

    diff --git tests/phpunit/tests/multisite/ms-files-rewriting.php tests/phpunit/tests/multisite/ms-files-rewriting.php
    index 611e843..8bc87df 100644
    class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { 
    3737
    3838                $site = get_current_site();
    3939
    40                 $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
    41                 $blog_id2 = self::$factory->blog->create( array( 'user_id' => $user_id ) );
     40                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     41                $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) );
    4242                $info = wp_upload_dir();
    4343                $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    4444                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { 
    6767                // Upload a file to the main site on the network.
    6868                $file1 = wp_upload_bits( $filename, null, $contents );
    6969
    70                 $blog_id = self::$factory->blog->create();
     70                $blog_id = self::factory()->blog->create();
    7171
    7272                switch_to_blog( $blog_id );
    7373                $file2 = wp_upload_bits( $filename, null, $contents );
  • tests/phpunit/tests/multisite/network.php

    diff --git tests/phpunit/tests/multisite/network.php tests/phpunit/tests/multisite/network.php
    index 01160ad..5888c73 100644
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    3737         * as the main network ID.
    3838         */
    3939        function test_get_main_network_id_two_networks() {
    40                 self::$factory->network->create();
     40                self::factory()->network->create();
    4141
    4242                $this->assertEquals( 1, get_main_network_id() );
    4343        }
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    4949        function test_get_main_network_id_after_network_switch() {
    5050                global $current_site;
    5151
    52                 $id = self::$factory->network->create();
     52                $id = self::factory()->network->create();
    5353
    5454                $current_site->id = (int) $id;
    5555
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    6565         */
    6666        function test_get_main_network_id_after_network_delete() {
    6767                global $wpdb, $current_site;
    68                 $id = self::$factory->network->create();
     68                $id = self::factory()->network->create();
    6969
    7070                $current_site->id = (int) $id;
    7171                $wpdb->query( "UPDATE {$wpdb->site} SET id=100 WHERE id=1" );
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    9090                $site_count_start = get_blog_count();
    9191                // false for large networks by default
    9292                add_filter( 'enable_live_network_counts', '__return_false' );
    93                 self::$factory->blog->create_many( 4 );
     93                self::factory()->blog->create_many( 4 );
    9494
    9595                // count only updated when cron runs, so unchanged
    9696                $this->assertEquals( $site_count_start, (int) get_blog_count() );
    9797
    9898                add_filter( 'enable_live_network_counts', '__return_true' );
    99                 $site_ids = self::$factory->blog->create_many( 4 );
     99                $site_ids = self::factory()->blog->create_many( 4 );
    100100
    101101                $this->assertEquals( $site_count_start + 9, (int) get_blog_count() );
    102102
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    211211
    212212                // Only false for large networks as of 3.7
    213213                add_filter( 'enable_live_network_counts', '__return_false' );
    214                 self::$factory->user->create( array( 'role' => 'administrator' ) );
     214                self::factory()->user->create( array( 'role' => 'administrator' ) );
    215215
    216216                $count = get_user_count(); // No change, cache not refreshed
    217217                $this->assertEquals( $start_count, $count );
    class Tests_Multisite_Network extends WP_UnitTestCase { 
    240240                $dashboard_blog = get_dashboard_blog();
    241241                $this->assertEquals( 1, $dashboard_blog->blog_id );
    242242
    243                 $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
    244                 $blog_id = self::$factory->blog->create( array( 'user_id' => $user_id ) );
     243                $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     244                $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) );
    245245                $this->assertInternalType( 'int', $blog_id );
    246246
    247247                // set the dashboard blog to another one
  • tests/phpunit/tests/multisite/site.php

    diff --git tests/phpunit/tests/multisite/site.php tests/phpunit/tests/multisite/site.php
    index 0a51e6a..8afdbe8 100644
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    3434                wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' );
    3535                $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
    3636
    37                 $blog_id = self::$factory->blog->create();
     37                $blog_id = self::factory()->blog->create();
    3838
    3939                $cap_key = wp_get_current_user()->cap_key;
    4040                switch_to_blog( $blog_id );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    7474        function test_created_site_details() {
    7575                global $wpdb;
    7676
    77                 $blog_id = self::$factory->blog->create();
     77                $blog_id = self::factory()->blog->create();
    7878
    7979                $this->assertInternalType( 'int', $blog_id );
    8080                $prefix = $wpdb->get_blog_prefix( $blog_id );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    130130         * When a site is flagged as 'deleted', its data should be cleared from cache.
    131131         */
    132132        function test_data_in_cache_after_wpmu_delete_blog_drop_false() {
    133                 $blog_id = self::$factory->blog->create();
     133                $blog_id = self::factory()->blog->create();
    134134
    135135                $details = get_blog_details( $blog_id, false );
    136136                $key = md5( $details->domain . $details->path );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    151151        function test_data_in_tables_after_wpmu_delete_blog_drop_false() {
    152152                global $wpdb;
    153153
    154                 $blog_id = self::$factory->blog->create();
     154                $blog_id = self::factory()->blog->create();
    155155
    156156                // Delete the site without forcing a table drop.
    157157                wpmu_delete_blog( $blog_id, false );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    169169         * When a site is fully deleted, its data should be cleared from cache.
    170170         */
    171171        function test_data_in_cache_after_wpmu_delete_blog_drop_true() {
    172                 $blog_id = self::$factory->blog->create();
     172                $blog_id = self::factory()->blog->create();
    173173
    174174                $details = get_blog_details( $blog_id, false );
    175175                $key = md5( $details->domain . $details->path );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    190190        function test_data_in_tables_after_wpmu_delete_blog_drop_true() {
    191191                global $wpdb;
    192192
    193                 $blog_id = self::$factory->blog->create();
     193                $blog_id = self::factory()->blog->create();
    194194
    195195                // Delete the site and force a table drop.
    196196                wpmu_delete_blog( $blog_id, true );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    247247         * The site count of a network should change when a site is flagged as 'deleted'.
    248248         */
    249249        function test_network_count_after_wpmu_delete_blog_drop_false() {
    250                 $blog_id = self::$factory->blog->create();
     250                $blog_id = self::factory()->blog->create();
    251251
    252252                // Delete the site without forcing a table drop.
    253253                wpmu_delete_blog( $blog_id, false );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    261261         * The site count of a network should change when a site is fully deleted.
    262262         */
    263263        function test_blog_count_after_wpmu_delete_blog_drop_true() {
    264                 $blog_id = self::$factory->blog->create();
     264                $blog_id = self::factory()->blog->create();
    265265
    266266                // Delete the site and force a table drop.
    267267                wpmu_delete_blog( $blog_id, true );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    283283                // Upload a file to the main site on the network.
    284284                $file1 = wp_upload_bits( $filename, null, $contents );
    285285
    286                 $blog_id = self::$factory->blog->create();
     286                $blog_id = self::factory()->blog->create();
    287287
    288288                switch_to_blog( $blog_id );
    289289                $file2 = wp_upload_bits( $filename, null, $contents );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    329329         */
    330330        function test_get_blog_details_when_site_does_not_exist() {
    331331                // Create an unused site so that we can then assume an invalid site ID.
    332                 $blog_id = self::$factory->blog->create();
     332                $blog_id = self::factory()->blog->create();
    333333                $blog_id++;
    334334
    335335                // Prime the cache for an invalid site.
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    339339                $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) );
    340340
    341341                // Create a site in the invalid site's place.
    342                 self::$factory->blog->create();
     342                self::factory()->blog->create();
    343343
    344344                // When a new site is created, its cache is cleared through refresh_blog_details.
    345345                $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' )  );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    370370                global $test_action_counter;
    371371                $test_action_counter = 0;
    372372
    373                 $blog_id = self::$factory->blog->create();
     373                $blog_id = self::factory()->blog->create();
    374374                update_blog_details( $blog_id, array( 'spam' => 1 ) );
    375375
    376376                add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    394394                global $test_action_counter;
    395395                $test_action_counter = 0;
    396396
    397                 $blog_id = self::$factory->blog->create();
     397                $blog_id = self::factory()->blog->create();
    398398
    399399                add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 );
    400400                update_blog_status( $blog_id, 'spam', 1 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    417417                global $test_action_counter;
    418418                $test_action_counter = 0;
    419419
    420                 $blog_id = self::$factory->blog->create();
     420                $blog_id = self::factory()->blog->create();
    421421
    422422                add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 );
    423423                update_blog_status( $blog_id, 'archived', 1 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    440440                global $test_action_counter;
    441441                $test_action_counter = 0;
    442442
    443                 $blog_id = self::$factory->blog->create();
     443                $blog_id = self::factory()->blog->create();
    444444                update_blog_details( $blog_id, array( 'archived' => 1 ) );
    445445
    446446                add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    463463                global $test_action_counter;
    464464                $test_action_counter = 0;
    465465
    466                 $blog_id = self::$factory->blog->create();
     466                $blog_id = self::factory()->blog->create();
    467467
    468468                add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 );
    469469                update_blog_status( $blog_id, 'deleted', 1 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    486486                global $test_action_counter;
    487487                $test_action_counter = 0;
    488488
    489                 $blog_id = self::$factory->blog->create();
     489                $blog_id = self::factory()->blog->create();
    490490                update_blog_details( $blog_id, array( 'deleted' => 1 ) );
    491491
    492492                add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    510510                global $test_action_counter;
    511511                $test_action_counter = 0;
    512512
    513                 $blog_id = self::$factory->blog->create();
     513                $blog_id = self::factory()->blog->create();
    514514
    515515                add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 );
    516516                update_blog_status( $blog_id, 'mature', 1 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    533533                global $test_action_counter;
    534534                $test_action_counter = 0;
    535535
    536                 $blog_id = self::$factory->blog->create();
     536                $blog_id = self::factory()->blog->create();
    537537                update_blog_details( $blog_id, array( 'mature' => 1 ) );
    538538
    539539                add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    557557                global $test_action_counter;
    558558                $test_action_counter = 0;
    559559
    560                 $blog_id = self::$factory->blog->create();
     560                $blog_id = self::factory()->blog->create();
    561561
    562562                add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 );
    563563                update_blog_status( $blog_id, 'public', 0 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    583583         * @ticket 14511
    584584         */
    585585        function test_wp_get_sites_with_default_arguments() {
    586                 self::$factory->blog->create( array( 'site_id' => 2 ) );
     586                self::factory()->blog->create( array( 'site_id' => 2 ) );
    587587
    588588                $this->assertCount( 1, wp_get_sites() );
    589589        }
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    599599         * A network ID of null should query for all public sites on all networks.
    600600         */
    601601        function test_wp_get_sites_with_network_id_null() {
    602                 self::$factory->blog->create( array( 'site_id' => 2 ) );
     602                self::factory()->blog->create( array( 'site_id' => 2 ) );
    603603
    604604                $this->assertCount( 2, wp_get_sites( array( 'network_id' => null ) ) );
    605605        }
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    608608         * Expect only sites on the specified network ID to be returned.
    609609         */
    610610        function test_wp_get_sites_with_specific_network_id() {
    611                 self::$factory->blog->create( array( 'site_id' => 2 ) );
     611                self::factory()->blog->create( array( 'site_id' => 2 ) );
    612612
    613613                $this->assertCount( 1, wp_get_sites( array( 'network_id' => 2 ) ) );
    614614        }
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    617617         * Expect sites from both networks if both network IDs are specified.
    618618         */
    619619        function test_wp_get_sites_with_multiple_network_ids() {
    620                 self::$factory->blog->create( array( 'site_id' => 2 ) );
     620                self::factory()->blog->create( array( 'site_id' => 2 ) );
    621621
    622622                $this->assertCount( 2, wp_get_sites( array( 'network_id' => array( 1, 2 ) ) ) );
    623623        }
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    626626         * Queries for public or non public sites should work across all networks if network ID is null.
    627627         */
    628628        function test_wp_get_sites_with_public_meta_on_all_networks() {
    629                 self::$factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) );
     629                self::factory()->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) );
    630630
    631631                $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => null ) ) );
    632632                $this->assertcount( 1, wp_get_sites( array( 'public' => 0, 'network_id' => null ) ) );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    636636         * If a network ID is specified, queries for public sites should be restricted to that network.
    637637         */
    638638        function test_wp_get_sites_with_public_meta_restrict_to_one_network() {
    639                 self::$factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) );
     639                self::factory()->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) );
    640640
    641641                $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => 1 ) ) );
    642642                $this->assertCount( 0, wp_get_sites( array( 'public' => 1, 'network_id' => 2 ) ) );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    647647         */
    648648        function test_wp_get_sites_limit_offset() {
    649649                // Create 2 more sites (in addition to the default one)
    650                 self::$factory->blog->create_many( 2 );
     650                self::factory()->blog->create_many( 2 );
    651651
    652652                // Expect first 2 sites when using limit
    653653                $this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    670670         * @ticket 27952
    671671         */
    672672        function test_posts_count() {
    673                 self::$factory->post->create();
    674                 $post2 = self::$factory->post->create();
     673                self::factory()->post->create();
     674                $post2 = self::factory()->post->create();
    675675                $this->assertEquals( 2, get_blog_details()->post_count );
    676676
    677677                wp_delete_post( $post2 );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    701701                );
    702702
    703703                foreach ( $network_ids as &$id ) {
    704                         $id = self::$factory->network->create( $id );
     704                        $id = self::factory()->network->create( $id );
    705705                }
    706706                unset( $id );
    707707
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    714714                );
    715715
    716716                foreach ( $ids as &$id ) {
    717                         $id = self::$factory->blog->create( $id );
     717                        $id = self::factory()->blog->create( $id );
    718718                }
    719719                unset( $id );
    720720
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    772772         * the blog ID is requested through get_blog_id_from_url().
    773773         */
    774774        function test_get_blog_id_from_url() {
    775                 $blog_id = self::$factory->blog->create();
     775                $blog_id = self::factory()->blog->create();
    776776                $details = get_blog_details( $blog_id, false );
    777777                $key = md5( $details->domain . $details->path );
    778778
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    785785         * Test the case insensitivity of the site lookup.
    786786         */
    787787        function test_get_blog_id_from_url_is_case_insensitive() {
    788                 $blog_id = self::$factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) );
     788                $blog_id = self::factory()->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) );
    789789                $details = get_blog_details( $blog_id, false );
    790790
    791791                $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    795795         * Test the first and cached responses for a site that does not exist.
    796796         */
    797797        function test_get_blog_id_from_url_that_does_not_exist() {
    798                 $blog_id = self::$factory->blog->create( array( 'path' => '/xyz' ) );
     798                $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) );
    799799                $details = get_blog_details( $blog_id, false );
    800800
    801801                $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    807807         * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`.
    808808         */
    809809        function test_get_blog_id_from_url_with_deleted_flag() {
    810                 $blog_id = self::$factory->blog->create();
     810                $blog_id = self::factory()->blog->create();
    811811                $details = get_blog_details( $blog_id, false );
    812812                $key = md5( $details->domain . $details->path );
    813813                wpmu_delete_blog( $blog_id );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    821821         * -1 after an attempt at `get_blog_id_from_url()` is made.
    822822         */
    823823        function test_get_blog_id_from_url_after_dropped() {
    824                 $blog_id = self::$factory->blog->create();
     824                $blog_id = self::factory()->blog->create();
    825825                $details = get_blog_details( $blog_id, false );
    826826                $key = md5( $details->domain . $details->path );
    827827                wpmu_delete_blog( $blog_id, true );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    850850         * Test with a site ID other than the main site to ensure a false response.
    851851         */
    852852        function test_is_main_site_is_false_with_other_blog_id() {
    853                 $blog_id = self::$factory->blog->create();
     853                $blog_id = self::factory()->blog->create();
    854854
    855855                $this->assertFalse( is_main_site( $blog_id ) );
    856856        }
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    859859         * Test with no passed ID after switching to another site ID.
    860860         */
    861861        function test_is_main_site_is_false_after_switch_to_blog() {
    862                 $blog_id = self::$factory->blog->create();
     862                $blog_id = self::factory()->blog->create();
    863863                switch_to_blog( $blog_id );
    864864
    865865                $this->assertFalse( is_main_site() );
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    878878                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    879879                $this->assertEquals( '', $info['error'] );
    880880
    881                 $blog_id = self::$factory->blog->create();
     881                $blog_id = self::factory()->blog->create();
    882882
    883883                switch_to_blog( $blog_id );
    884884                $info = wp_upload_dir();
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    900900         * another site on the network.
    901901         */
    902902        function test_get_blog_post_from_another_site_on_network() {
    903                 $blog_id = self::$factory->blog->create();
    904                 $post_id = self::$factory->post->create(); // Create a post on the primary site, ID 1.
     903                $blog_id = self::factory()->blog->create();
     904                $post_id = self::factory()->post->create(); // Create a post on the primary site, ID 1.
    905905                $post = get_post( $post_id );
    906906                switch_to_blog( $blog_id );
    907907
    class Tests_Multisite_Site extends WP_UnitTestCase { 
    915915         * If get_blog_post() is used on the same site, it should still work.
    916916         */
    917917        function test_get_blog_post_from_same_site() {
    918                 $post_id = self::$factory->post->create();
     918                $post_id = self::factory()->post->create();
    919919
    920920                $this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) );
    921921        }
  • tests/phpunit/tests/multisite/updateBlogDetails.php

    diff --git tests/phpunit/tests/multisite/updateBlogDetails.php tests/phpunit/tests/multisite/updateBlogDetails.php
    index 874d2bc..e106b02 100644
    class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { 
    2525        }
    2626
    2727        function test_update_blog_details() {
    28                 $blog_id = self::$factory->blog->create();
     28                $blog_id = self::factory()->blog->create();
    2929
    3030                $result = update_blog_details( $blog_id, array( 'domain' => 'example.com', 'path' => 'my_path/' ) );
    3131
    class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { 
    5353                global $test_action_counter;
    5454                $test_action_counter = 0;
    5555
    56                 $blog_id = self::$factory->blog->create();
     56                $blog_id = self::factory()->blog->create();
    5757
    5858                // Set an initial value of '1' for the flag when '0' is the flag value being tested.
    5959                if ( '0' === $flag_value ) {
  • tests/phpunit/tests/multisite/wpmuValidateUserSignup.php

    diff --git tests/phpunit/tests/multisite/wpmuValidateUserSignup.php tests/phpunit/tests/multisite/wpmuValidateUserSignup.php
    index 50ddce7..15cf56c 100644
    class Tests_Multisite_WpmuValidateUserSignup extends WP_UnitTestCase { 
    6363        }
    6464
    6565        public function test_should_fail_for_existing_user_name() {
    66                 $u = self::$factory->user->create( array( 'user_login' => 'foo123' ) );
     66                $u = self::factory()->user->create( array( 'user_login' => 'foo123' ) );
    6767                $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
    6868                $this->assertContains( 'user_name', $v['errors']->get_error_codes() );
    6969        }
    7070
    7171        public function test_should_fail_for_existing_user_email() {
    72                 $u = self::$factory->user->create( array( 'user_email' => 'foo@example.com' ) );
     72                $u = self::factory()->user->create( array( 'user_email' => 'foo@example.com' ) );
    7373                $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
    7474                $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
    7575        }
  • tests/phpunit/tests/oembed/controller.php

    diff --git tests/phpunit/tests/oembed/controller.php tests/phpunit/tests/oembed/controller.php
    index 9c9275b..bf646f5 100644
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    1717        }
    1818
    1919        function test_request_json() {
    20                 $user = self::$factory->user->create_and_get( array(
     20                $user = self::factory()->user->create_and_get( array(
    2121                        'display_name' => 'John Doe',
    2222                ) );
    23                 $post = self::$factory->post->create_and_get( array(
     23                $post = self::factory()->post->create_and_get( array(
    2424                        'post_author' => $user->ID,
    2525                        'post_title'  => 'Hello World',
    2626                ) );
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    6060        }
    6161
    6262        function test_request_jsonp() {
    63                 $user = self::$factory->user->create_and_get( array(
     63                $user = self::factory()->user->create_and_get( array(
    6464                        'display_name' => 'John Doe',
    6565                ) );
    66                 $post = self::$factory->post->create_and_get( array(
     66                $post = self::factory()->post->create_and_get( array(
    6767                        'post_author' => $user->ID,
    6868                        'post_title'  => 'Hello World',
    6969                ) );
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    8383        }
    8484
    8585        function test_request_jsonp_invalid_callback() {
    86                 $user = self::$factory->user->create_and_get( array(
     86                $user = self::factory()->user->create_and_get( array(
    8787                        'display_name' => 'John Doe',
    8888                ) );
    89                 $post = self::$factory->post->create_and_get( array(
     89                $post = self::factory()->post->create_and_get( array(
    9090                        'post_author' => $user->ID,
    9191                        'post_title'  => 'Hello World',
    9292                ) );
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    118118        }
    119119
    120120        function test_request_xml() {
    121                 $user = self::$factory->user->create_and_get( array(
     121                $user = self::factory()->user->create_and_get( array(
    122122                        'display_name' => 'John Doe',
    123123                ) );
    124                 $post = self::$factory->post->create_and_get( array(
     124                $post = self::factory()->post->create_and_get( array(
    125125                        'post_author' => $user->ID,
    126126                        'post_title'  => 'Hello World',
    127127                ) );
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    177177                        $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    178178                }
    179179
    180                 $child = self::$factory->blog->create();
     180                $child = self::factory()->blog->create();
    181181
    182182                switch_to_blog( $child );
    183183
    184                 $post = self::$factory->post->create_and_get( array(
     184                $post = self::factory()->post->create_and_get( array(
    185185                        'post_title' => 'Hello Child Blog',
    186186                ) );
    187187
    class Test_oEmbed_Controller extends WP_UnitTestCase { 
    207207                $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) );
    208208                $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) );
    209209
    210                 $post_id     = self::$factory->post->create();
     210                $post_id     = self::factory()->post->create();
    211211                $url         = get_permalink( $post_id );
    212212                $url_encoded = urlencode( $url );
    213213
  • tests/phpunit/tests/oembed/discovery.php

    diff --git tests/phpunit/tests/oembed/discovery.php tests/phpunit/tests/oembed/discovery.php
    index ef78bef..e7615f9 100644
    class Tests_oEmbed_Discovery extends WP_UnitTestCase { 
    1212        }
    1313
    1414        function test_add_oembed_discovery_links_to_post() {
    15                 $post_id = self::$factory->post->create();
     15                $post_id = self::factory()->post->create();
    1616                $this->go_to( get_permalink( $post_id ) );
    1717
    1818                $this->assertQueryTrue( 'is_single', 'is_singular' );
    class Tests_oEmbed_Discovery extends WP_UnitTestCase { 
    2828        }
    2929
    3030        function test_add_oembed_discovery_links_to_page() {
    31                 $post_id = self::$factory->post->create( array(
     31                $post_id = self::factory()->post->create( array(
    3232                        'post_type' => 'page'
    3333                ));
    3434                $this->go_to( get_permalink( $post_id ) );
    class Tests_oEmbed_Discovery extends WP_UnitTestCase { 
    4646        }
    4747
    4848        function test_add_oembed_discovery_links_to_attachment() {
    49                 $post_id       = self::$factory->post->create();
     49                $post_id       = self::factory()->post->create();
    5050                $file          = DIR_TESTDATA . '/images/canola.jpg';
    51                 $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
     51                $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array(
    5252                        'post_mime_type' => 'image/jpeg',
    5353                ) );
    5454
  • tests/phpunit/tests/oembed/getResponseData.php

    diff --git tests/phpunit/tests/oembed/getResponseData.php tests/phpunit/tests/oembed/getResponseData.php
    index 0891642..6dcdcbd 100644
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    99        }
    1010
    1111        function test_get_oembed_response_data() {
    12                 $post = self::$factory->post->create_and_get( array(
     12                $post = self::factory()->post->create_and_get( array(
    1313                        'post_title' => 'Some Post',
    1414                ) );
    1515
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    3333         * Test get_oembed_response_data with an author.
    3434         */
    3535        function test_get_oembed_response_data_author() {
    36                 $user_id = self::$factory->user->create( array(
     36                $user_id = self::factory()->user->create( array(
    3737                        'display_name' => 'John Doe',
    3838                ) );
    3939
    40                 $post = self::$factory->post->create_and_get( array(
     40                $post = self::factory()->post->create_and_get( array(
    4141                        'post_title'  => 'Some Post',
    4242                        'post_author' => $user_id,
    4343                ) );
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    6161        function test_get_oembed_response_link() {
    6262                remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich' );
    6363
    64                 $post = self::$factory->post->create_and_get( array(
     64                $post = self::factory()->post->create_and_get( array(
    6565                        'post_title' => 'Some Post',
    6666                ) );
    6767
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    8181        }
    8282
    8383        function test_get_oembed_response_data_with_draft_post() {
    84                 $post = self::$factory->post->create_and_get( array(
     84                $post = self::factory()->post->create_and_get( array(
    8585                        'post_status' => 'draft',
    8686                ) );
    8787
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    8989        }
    9090
    9191        function test_get_oembed_response_data_with_scheduled_post() {
    92                 $post = self::$factory->post->create_and_get( array(
     92                $post = self::factory()->post->create_and_get( array(
    9393                        'post_status' => 'future',
    9494                        'post_date'   => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ),
    9595                ) );
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    9898        }
    9999
    100100        function test_get_oembed_response_data_with_private_post() {
    101                 $post = self::$factory->post->create_and_get( array(
     101                $post = self::factory()->post->create_and_get( array(
    102102                        'post_status' => 'private',
    103103                ) );
    104104
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    106106        }
    107107
    108108        function test_get_oembed_response_data_maxwidth_too_high() {
    109                 $post = self::$factory->post->create_and_get();
     109                $post = self::factory()->post->create_and_get();
    110110
    111111                $data = get_oembed_response_data( $post, 1000 );
    112112
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    115115        }
    116116
    117117        function test_get_oembed_response_data_maxwidth_too_low() {
    118                 $post = self::$factory->post->create_and_get();
     118                $post = self::factory()->post->create_and_get();
    119119
    120120                $data = get_oembed_response_data( $post, 100 );
    121121
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    124124        }
    125125
    126126        function test_get_oembed_response_data_maxwidth_invalid() {
    127                 $post = self::$factory->post->create_and_get();
     127                $post = self::factory()->post->create_and_get();
    128128
    129129                $data = get_oembed_response_data( $post, '400;" DROP TABLES' );
    130130
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    138138        }
    139139
    140140        function test_get_oembed_response_data_with_thumbnail() {
    141                 $post          = self::$factory->post->create_and_get();
     141                $post          = self::factory()->post->create_and_get();
    142142                $file          = DIR_TESTDATA . '/images/canola.jpg';
    143                 $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array(
     143                $attachment_id = self::factory()->attachment->create_object( $file, $post->ID, array(
    144144                        'post_mime_type' => 'image/jpeg',
    145145                ) );
    146146                set_post_thumbnail( $post, $attachment_id );
    class Tests_oEmbed_Response_Data extends WP_UnitTestCase { 
    154154        }
    155155
    156156        function test_get_oembed_response_data_for_attachment() {
    157                 $parent = self::$factory->post->create();
     157                $parent = self::factory()->post->create();
    158158                $file   = DIR_TESTDATA . '/images/canola.jpg';
    159                 $post   = self::$factory->attachment->create_object( $file, $parent, array(
     159                $post   = self::factory()->attachment->create_object( $file, $parent, array(
    160160                        'post_mime_type' => 'image/jpeg',
    161161                ) );
    162162
  • tests/phpunit/tests/oembed/headers.php

    diff --git tests/phpunit/tests/oembed/headers.php tests/phpunit/tests/oembed/headers.php
    index 247e947..3c9f80f 100644
    class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { 
    1212                        $this->markTestSkipped( 'xdebug is required for this test' );
    1313                }
    1414
    15                 $post = self::$factory->post->create_and_get( array(
     15                $post = self::factory()->post->create_and_get( array(
    1616                        'post_title'  => 'Hello World',
    1717                ) );
    1818
    class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { 
    4646                        $this->markTestSkipped( 'xdebug is required for this test' );
    4747                }
    4848
    49                 $post = self::$factory->post->create_and_get( array(
     49                $post = self::factory()->post->create_and_get( array(
    5050                        'post_title'  => 'Hello World',
    5151                ) );
    5252
  • tests/phpunit/tests/oembed/postEmbedUrl.php

    diff --git tests/phpunit/tests/oembed/postEmbedUrl.php tests/phpunit/tests/oembed/postEmbedUrl.php
    index 1972bac..dda0f3c 100644
    class Tests_Post_Embed_URL extends WP_UnitTestCase { 
    1212        function test_get_post_embed_url_with_pretty_permalinks() {
    1313                update_option( 'permalink_structure', '/%postname%' );
    1414
    15                 $post_id   = self::$factory->post->create();
     15                $post_id   = self::factory()->post->create();
    1616                $permalink = get_permalink( $post_id );
    1717                $embed_url = get_post_embed_url( $post_id );
    1818
    class Tests_Post_Embed_URL extends WP_UnitTestCase { 
    2222        }
    2323
    2424        function test_get_post_embed_url_with_ugly_permalinks() {
    25                 $post_id   = self::$factory->post->create();
     25                $post_id   = self::factory()->post->create();
    2626                $permalink = get_permalink( $post_id );
    2727                $embed_url = get_post_embed_url( $post_id );
    2828
  • tests/phpunit/tests/oembed/template.php

    diff --git tests/phpunit/tests/oembed/template.php tests/phpunit/tests/oembed/template.php
    index 94d0d9c..da61db4 100644
     
    55 */
    66class Tests_Embed_Template extends WP_UnitTestCase {
    77        function test_oembed_output_post() {
    8                 $user = self::$factory->user->create_and_get( array(
     8                $user = self::factory()->user->create_and_get( array(
    99                        'display_name' => 'John Doe',
    1010                ) );
    1111
    12                 $post_id = self::$factory->post->create( array(
     12                $post_id = self::factory()->post->create( array(
    1313                        'post_author'  => $user->ID,
    1414                        'post_title'   => 'Hello World',
    1515                        'post_content' => 'Foo Bar',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    3030        }
    3131
    3232        function test_oembed_output_post_with_thumbnail() {
    33                 $post_id       = self::$factory->post->create( array(
     33                $post_id       = self::factory()->post->create( array(
    3434                        'post_title'   => 'Hello World',
    3535                        'post_content' => 'Foo Bar',
    3636                        'post_excerpt' => 'Bar Baz',
    3737                ) );
    3838                $file          = DIR_TESTDATA . '/images/canola.jpg';
    39                 $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
     39                $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array(
    4040                        'post_mime_type' => 'image/jpeg',
    4141                ) );
    4242                set_post_thumbnail( $post_id, $attachment_id );
    class Tests_Embed_Template extends WP_UnitTestCase { 
    7272        }
    7373
    7474        function test_oembed_output_attachment() {
    75                 $post          = self::$factory->post->create_and_get();
     75                $post          = self::factory()->post->create_and_get();
    7676                $file          = DIR_TESTDATA . '/images/canola.jpg';
    77                 $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array(
     77                $attachment_id = self::factory()->attachment->create_object( $file, $post->ID, array(
    7878                        'post_mime_type' => 'image/jpeg',
    7979                        'post_title'     => 'Hello World',
    8080                        'post_content'   => 'Foo Bar',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    9797        }
    9898
    9999        function test_oembed_output_draft_post() {
    100                 $post_id = self::$factory->post->create( array(
     100                $post_id = self::factory()->post->create( array(
    101101                        'post_title'   => 'Hello World',
    102102                        'post_content' => 'Foo Bar',
    103103                        'post_excerpt' => 'Bar Baz',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    118118        }
    119119
    120120        function test_oembed_output_scheduled_post() {
    121                 $post_id = self::$factory->post->create( array(
     121                $post_id = self::factory()->post->create( array(
    122122                        'post_title'   => 'Hello World',
    123123                        'post_content' => 'Foo Bar',
    124124                        'post_excerpt' => 'Bar Baz',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    140140        }
    141141
    142142        function test_oembed_output_private_post() {
    143                 $post_id = self::$factory->post->create( array(
     143                $post_id = self::factory()->post->create( array(
    144144                        'post_title'   => 'Hello World',
    145145                        'post_content' => 'Foo Bar',
    146146                        'post_excerpt' => 'Bar Baz',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    161161        }
    162162
    163163        function test_oembed_output_private_post_with_permissions() {
    164                 $user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     164                $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    165165                wp_set_current_user( $user_id );
    166166
    167                 $post_id = self::$factory->post->create( array(
     167                $post_id = self::factory()->post->create( array(
    168168                        'post_title'   => 'Hello World',
    169169                        'post_content' => 'Foo Bar',
    170170                        'post_excerpt' => 'Bar Baz',
    class Tests_Embed_Template extends WP_UnitTestCase { 
    193193        }
    194194
    195195        function test_wp_embed_excerpt_more() {
    196                 $post_id = self::$factory->post->create( array(
     196                $post_id = self::factory()->post->create( array(
    197197                        'post_content' => 'Foo Bar',
    198198                ) );
    199199
    class Tests_Embed_Template extends WP_UnitTestCase { 
    214214        function test_is_embed_post() {
    215215                $this->assertFalse( is_embed() );
    216216
    217                 $post_id = self::$factory->post->create();
     217                $post_id = self::factory()->post->create();
    218218                $this->go_to( get_post_embed_url( $post_id ) );
    219219                $this->assertTrue( is_embed() );
    220220        }
    221221
    222222        function test_is_embed_attachment() {
    223                 $post_id       = self::$factory->post->create();
     223                $post_id       = self::factory()->post->create();
    224224                $file          = DIR_TESTDATA . '/images/canola.jpg';
    225                 $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
     225                $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array(
    226226                        'post_mime_type' => 'image/jpeg',
    227227                ) );
    228228                $this->go_to( get_post_embed_url( $attachment_id ) );
    class Tests_Embed_Template extends WP_UnitTestCase { 
    240240        }
    241241
    242242        function test_get_post_embed_html() {
    243                 $post_id = self::$factory->post->create();
     243                $post_id = self::factory()->post->create();
    244244
    245245                $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
    246246
  • tests/phpunit/tests/option/multisite.php

    diff --git tests/phpunit/tests/option/multisite.php tests/phpunit/tests/option/multisite.php
    index 627b655..5cde7ba 100644
    class Tests_Multisite_Option extends WP_UnitTestCase { 
    9898        }
    9999
    100100        function test_with_another_site() {
    101                 $user_id = self::$factory->user->create();
     101                $user_id = self::factory()->user->create();
    102102                $this->assertInternalType( 'integer', $user_id );
    103103
    104                 $blog_id = self::$factory->blog->create( array(
     104                $blog_id = self::factory()->blog->create( array(
    105105                        'user_id' => $user_id,
    106106                        'meta'    => array(
    107107                                'public' => 1,
  • tests/phpunit/tests/option/networkOption.php

    diff --git tests/phpunit/tests/option/networkOption.php tests/phpunit/tests/option/networkOption.php
    index f57c796..1e0bd71 100644
    if ( is_multisite() ) : 
    1111 */
    1212class Tests_Option_NetworkOption extends WP_UnitTestCase {
    1313        function test_add_network_option_not_available_on_other_network() {
    14                 $id = self::$factory->network->create();
     14                $id = self::factory()->network->create();
    1515                $option = rand_str();
    1616                $value = rand_str();
    1717
    class Tests_Option_NetworkOption extends WP_UnitTestCase { 
    2020        }
    2121
    2222        function test_add_network_option_available_on_same_network() {
    23                 $id = self::$factory->network->create();
     23                $id = self::factory()->network->create();
    2424                $option = rand_str();
    2525                $value = rand_str();
    2626
    class Tests_Option_NetworkOption extends WP_UnitTestCase { 
    2929        }
    3030
    3131        function test_delete_network_option_on_only_one_network() {
    32                 $id = self::$factory->network->create();
     32                $id = self::factory()->network->create();
    3333                $option = rand_str();
    3434                $value = rand_str();
    3535
  • tests/phpunit/tests/option/userSettings.php

    diff --git tests/phpunit/tests/option/userSettings.php tests/phpunit/tests/option/userSettings.php
    index 0c0aa3d..4da33e5 100644
    class Tests_User_Settings extends WP_UnitTestCase { 
    55        function setUp() {
    66                parent::setUp();
    77
    8                 $this->user_id = self::$factory->user->create( array(
     8                $this->user_id = self::factory()->user->create( array(
    99                        'role' => 'administrator'
    1010                ) );
    1111
  • tests/phpunit/tests/post.php

    diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
    index 17a93e4..df1ab0a 100644
    class Tests_Post extends WP_UnitTestCase { 
    545545        function test_get_page_by_path_priority() {
    546546                global $wpdb;
    547547
    548                 $attachment = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );
    549                 $page       = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );
    550                 $other_att  = self::$factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );
     548                $attachment = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );
     549                $page       = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );
     550                $other_att  = self::factory()->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );
    551551
    552552                $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) );
    553553                clean_post_cache( $page->ID );
    class Tests_Post extends WP_UnitTestCase { 
    565565        }
    566566
    567567        function test_wp_publish_post() {
    568                 $draft_id = self::$factory->post->create( array( 'post_status' => 'draft' ) );
     568                $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
    569569
    570570                $post = get_post( $draft_id );
    571571                $this->assertEquals( 'draft', $post->post_status );
    class Tests_Post extends WP_UnitTestCase { 
    581581         */
    582582        function test_wp_insert_post_and_wp_publish_post_with_future_date() {
    583583                $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );
    584                 $post_id = self::$factory->post->create( array(
     584                $post_id = self::factory()->post->create( array(
    585585                        'post_status' => 'publish',
    586586                        'post_date' => $future_date,
    587587                ) );
    class Tests_Post extends WP_UnitTestCase { 
    641641         * @ticket 22883
    642642         */
    643643        function test_get_page_uri_with_stdclass_post_object() {
    644                 $post_id    = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
     644                $post_id    = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
    645645
    646646                // Mimick an old stdClass post object, missing the ancestors field.
    647647                $post_array = (object) get_post( $post_id, ARRAY_A );
    class Tests_Post extends WP_UnitTestCase { 
    664664         * @ticket 15963
    665665         */
    666666        function test_get_post_uri_check_orphan() {
    667                 $parent_id = self::$factory->post->create( array( 'post_name' => 'parent' ) );
    668                 $child_id = self::$factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
     667                $parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) );
     668                $child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );
    669669
    670670                // check the parent for good measure
    671671                $this->assertEquals( 'parent', get_page_uri( $parent_id ) );
    class Tests_Post extends WP_UnitTestCase { 
    683683         */
    684684        function test_get_post_ancestors_within_loop() {
    685685                global $post;
    686                 $parent_id = self::$factory->post->create();
    687                 $post = self::$factory->post->create_and_get( array( 'post_parent' => $parent_id ) );
     686                $parent_id = self::factory()->post->create();
     687                $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
    688688                $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) );
    689689        }
    690690
    class Tests_Post extends WP_UnitTestCase { 
    692692         * @ticket 23474
    693693         */
    694694        function test_update_invalid_post_id() {
    695                 $post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
     695                $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
    696696                $post = get_post( $post_id, ARRAY_A );
    697697
    698698                $post['ID'] = 123456789;
    class Tests_Post extends WP_UnitTestCase { 
    707707
    708708        function test_parse_post_content_single_page() {
    709709                global $multipage, $pages, $numpages;
    710                 $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) );
     710                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
    711711                $post = get_post( $post_id );
    712712                setup_postdata( $post );
    713713                $this->assertEquals( 0, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    718718
    719719        function test_parse_post_content_multi_page() {
    720720                global $multipage, $pages, $numpages;
    721                 $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     721                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    722722                $post = get_post( $post_id );
    723723                setup_postdata( $post );
    724724                $this->assertEquals( 1, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    729729
    730730        function test_parse_post_content_remaining_single_page() {
    731731                global $multipage, $pages, $numpages;
    732                 $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) );
     732                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
    733733                $post = get_post( $post_id );
    734734                setup_postdata( $post );
    735735                $this->assertEquals( 0, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    740740
    741741        function test_parse_post_content_remaining_multi_page() {
    742742                global $multipage, $pages, $numpages;
    743                 $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     743                $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    744744                $post = get_post( $post_id );
    745745                setup_postdata( $post );
    746746                $this->assertEquals( 1, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    754754         */
    755755        function test_parse_post_content_starting_with_nextpage() {
    756756                global $multipage, $pages, $numpages;
    757                 $post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
     757                $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
    758758                $post = get_post( $post_id );
    759759                setup_postdata( $post );
    760760                $this->assertEquals( 1, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    768768         */
    769769        function test_parse_post_content_starting_with_nextpage_multi() {
    770770                global $multipage, $pages, $numpages;
    771                 $post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
     771                $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
    772772                $post = get_post( $post_id );
    773773                setup_postdata( $post );
    774774                $this->assertEquals( 0, $multipage );
    class Tests_Post extends WP_UnitTestCase { 
    809809        function test_wp_count_posts() {
    810810                $post_type = rand_str(20);
    811811                register_post_type( $post_type );
    812                 self::$factory->post->create( array(
     812                self::factory()->post->create( array(
    813813                        'post_type' => $post_type,
    814814                        'post_author' => self::$editor_id
    815815                ) );
    class Tests_Post extends WP_UnitTestCase { 
    822822        function test_wp_count_posts_filtered() {
    823823                $post_type = rand_str(20);
    824824                register_post_type( $post_type );
    825                 self::$factory->post->create_many( 3, array(
     825                self::factory()->post->create_many( 3, array(
    826826                        'post_type' => $post_type,
    827827                        'post_author' => self::$editor_id
    828828                ) );
    class Tests_Post extends WP_UnitTestCase { 
    842842        }
    843843
    844844        function test_wp_count_posts_insert_invalidation() {
    845                 $post_ids = self::$factory->post->create_many( 3 );
     845                $post_ids = self::factory()->post->create_many( 3 );
    846846                $initial_counts = wp_count_posts();
    847847
    848848                $key = array_rand( $post_ids );
    class Tests_Post extends WP_UnitTestCase { 
    860860        }
    861861
    862862        function test_wp_count_posts_trash_invalidation() {
    863                 $post_ids = self::$factory->post->create_many( 3 );
     863                $post_ids = self::factory()->post->create_many( 3 );
    864864                $initial_counts = wp_count_posts();
    865865
    866866                $key = array_rand( $post_ids );
    class Tests_Post extends WP_UnitTestCase { 
    881881         * @ticket 13771
    882882         */
    883883        function test_get_the_date_with_id_returns_correct_time() {
    884                 $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     884                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    885885                $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
    886886        }
    887887
    class Tests_Post extends WP_UnitTestCase { 
    899899         * @ticket 28310
    900900         */
    901901        function test_get_the_time_with_id_returns_correct_time() {
    902                 $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     902                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    903903                $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
    904904        }
    905905
    class Tests_Post extends WP_UnitTestCase { 
    917917         * @ticket 28310
    918918         */
    919919        function test_get_post_time_with_id_returns_correct_time() {
    920                 $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     920                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    921921                $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
    922922        }
    923923
    class Tests_Post extends WP_UnitTestCase { 
    935935         * @ticket 28310
    936936         */
    937937        function test_get_post_modified_time_with_id_returns_correct_time() {
    938                 $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     938                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    939939                $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
    940940        }
    941941
    class Tests_Post extends WP_UnitTestCase { 
    973973                register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
    974974                register_taxonomy( $tax, $post_type );
    975975
    976                 $post = self::$factory->post->create( array( 'post_type' => $post_type ) );
     976                $post = self::factory()->post->create( array( 'post_type' => $post_type ) );
    977977                wp_set_object_terms( $post, rand_str(), $tax );
    978978
    979979                $wp_tag_cloud = wp_tag_cloud( array(
    class Tests_Post extends WP_UnitTestCase { 
    10151015
    10161016                require_once( ABSPATH . '/wp-admin/includes/post.php' );
    10171017
    1018                 $post_id = self::$factory->post->create();
     1018                $post_id = self::factory()->post->create();
    10191019
    10201020                $data = array(
    10211021                        'post_ID'      => $post_id,
    class Tests_Post extends WP_UnitTestCase { 
    10431043         * @ticket 31168
    10441044         */
    10451045        function test_wp_insert_post_default_comment_ping_status_open() {
    1046                 $post_id = self::$factory->post->create( array(
     1046                $post_id = self::factory()->post->create( array(
    10471047                        'post_author' => self::$editor_id,
    10481048                        'post_status' => 'public',
    10491049                        'post_content' => rand_str(),
    class Tests_Post extends WP_UnitTestCase { 
    10591059         * @ticket 31168
    10601060         */
    10611061        function test_wp_insert_post_page_default_comment_ping_status_closed() {
    1062                 $post_id = self::$factory->post->create( array(
     1062                $post_id = self::factory()->post->create( array(
    10631063                        'post_author' => self::$editor_id,
    10641064                        'post_status' => 'public',
    10651065                        'post_content' => rand_str(),
    class Tests_Post extends WP_UnitTestCase { 
    10781078        function test_wp_insert_post_cpt_default_comment_ping_status_open() {
    10791079                $post_type = rand_str(20);
    10801080                register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
    1081                 $post_id = self::$factory->post->create( array(
     1081                $post_id = self::factory()->post->create( array(
    10821082                        'post_author' => self::$editor_id,
    10831083                        'post_status' => 'public',
    10841084                        'post_content' => rand_str(),
    class Tests_Post extends WP_UnitTestCase { 
    10981098        function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
    10991099                $post_type = rand_str(20);
    11001100                register_post_type( $post_type );
    1101                 $post_id = self::$factory->post->create( array(
     1101                $post_id = self::factory()->post->create( array(
    11021102                        'post_author' => self::$editor_id,
    11031103                        'post_status' => 'public',
    11041104                        'post_content' => rand_str(),
    class Tests_Post extends WP_UnitTestCase { 
    11271127                $this->assertTrue( current_user_can( 'edit_published_posts' ) );
    11281128
    11291129                // Create a sticky post.
    1130                 $post = self::$factory->post->create_and_get( array(
     1130                $post = self::factory()->post->create_and_get( array(
    11311131                        'post_title'   => 'Will be changed',
    11321132                        'post_content' => 'Will be changed',
    11331133                ) );
    class Tests_Post extends WP_UnitTestCase { 
    11561156         */
    11571157        function test_user_without_publish_cannot_affect_sticky_with_edit_post() {
    11581158                // Create a sticky post.
    1159                 $post = self::$factory->post->create_and_get( array(
     1159                $post = self::factory()->post->create_and_get( array(
    11601160                        'post_title'   => 'Will be changed',
    11611161                        'post_content' => 'Will be changed',
    11621162                ) );
    class Tests_Post extends WP_UnitTestCase { 
    11911191         * @ticket 32585
    11921192         */
    11931193        public function test_wp_insert_post_author_zero() {
    1194                 $post_id = self::$factory->post->create( array( 'post_author' => 0 ) );
     1194                $post_id = self::factory()->post->create( array( 'post_author' => 0 ) );
    11951195
    11961196                $this->assertEquals( 0, get_post( $post_id )->post_author );
    11971197        }
    class Tests_Post extends WP_UnitTestCase { 
    12001200         * @ticket 32585
    12011201         */
    12021202        public function test_wp_insert_post_author_null() {
    1203                 $post_id = self::$factory->post->create( array( 'post_author' => null ) );
     1203                $post_id = self::factory()->post->create( array( 'post_author' => null ) );
    12041204
    12051205                $this->assertEquals( self::$editor_id, get_post( $post_id )->post_author );
    12061206        }
  • tests/phpunit/tests/post/filtering.php

    diff --git tests/phpunit/tests/post/filtering.php tests/phpunit/tests/post/filtering.php
    index faabf28..91e79cf 100644
    EOF; 
    3131no such tag
    3232EOF;
    3333
    34                 $id = self::$factory->post->create( array( 'post_content' => $content ) );
     34                $id = self::factory()->post->create( array( 'post_content' => $content ) );
    3535                $post = get_post($id);
    3636
    3737                $this->assertEquals( $expected, $post->post_content );
    EOF; 
    4848<i>italics</i>
    4949EOF;
    5050
    51                 $id = self::$factory->post->create( array( 'post_content' => $content ) );
     51                $id = self::factory()->post->create( array( 'post_content' => $content ) );
    5252                $post = get_post($id);
    5353
    5454                $this->assertEquals( $expected, $post->post_content );
    EOF; 
    6565<img src='foo' width='500' />
    6666EOF;
    6767
    68                 $id = self::$factory->post->create( array( 'post_content' => $content ) );
     68                $id = self::factory()->post->create( array( 'post_content' => $content ) );
    6969                $post = get_post($id);
    7070
    7171                $this->assertEquals( $expected, $post->post_content );
    EOF; 
    8484<img src='foo' width='500' height='300' />
    8585EOF;
    8686
    87                 $id = self::$factory->post->create( array( 'post_content' => $content ) );
     87                $id = self::factory()->post->create( array( 'post_content' => $content ) );
    8888                $post = get_post($id);
    8989
    9090                $this->assertEquals( $expected, $post->post_content );
    that's continued after the jump</em> 
    104104breaks the graf</p>
    105105EOF;
    106106
    107                 $id = self::$factory->post->create( array( 'post_content' => $content ) );
     107                $id = self::factory()->post->create( array( 'post_content' => $content ) );
    108108                $post = get_post($id);
    109109
    110110                $this->assertEquals( $content, $post->post_content );
  • tests/phpunit/tests/post/formats.php

    diff --git tests/phpunit/tests/post/formats.php tests/phpunit/tests/post/formats.php
    index ecb9bf2..c28e19e 100644
    class Tests_Post_Formats extends WP_UnitTestCase { 
    99        }
    1010
    1111        function test_set_get_post_format_for_post() {
    12                 $post_id = self::$factory->post->create();
     12                $post_id = self::factory()->post->create();
    1313
    1414                $format = get_post_format( $post_id );
    1515                $this->assertFalse( $format );
    class Tests_Post_Formats extends WP_UnitTestCase { 
    3737         * @ticket 22473
    3838         */
    3939        function test_set_get_post_format_for_page() {
    40                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     40                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    4141
    4242                $format = get_post_format( $post_id );
    4343                $this->assertFalse( $format );
    class Tests_Post_Formats extends WP_UnitTestCase { 
    6969        }
    7070
    7171        function test_has_format() {
    72                 $post_id = self::$factory->post->create();
     72                $post_id = self::factory()->post->create();
    7373
    7474                $this->assertFalse( has_post_format( 'standard', $post_id ) );
    7575                $this->assertFalse( has_post_format( '', $post_id ) );
    $href 
    111111
    112112$commentary
    113113DATA;
    114                 $link_post_id = self::$factory->post->create( array( 'post_content' => $link ) );
     114                $link_post_id = self::factory()->post->create( array( 'post_content' => $link ) );
    115115                $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) );
    116116                $this->assertEquals( false, $content_link );
    117117
    118                 $link_with_post_id = self::$factory->post->create( array( 'post_content' => $link_with_commentary ) );
     118                $link_with_post_id = self::factory()->post->create( array( 'post_content' => $link_with_commentary ) );
    119119                $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
    120120                $this->assertEquals( false, $content_link );
    121121
    DATA; 
    125125                $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
    126126                $this->assertEquals( false, $content_link );
    127127
    128                 $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
     128                $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    129129                $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
    130130                $this->assertEquals( false, $content_link );
    131131
    132                 $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
     132                $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) );
    133133                $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
    134134                $this->assertEquals( false, $content_link );
    135135
    136136                // Now with an href
    137                 $href_post_id = self::$factory->post->create( array( 'post_content' => $href ) );
     137                $href_post_id = self::factory()->post->create( array( 'post_content' => $href ) );
    138138                $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) );
    139139                $this->assertEquals( $link, $content_link );
    140140
    141                 $href_with_post_id = self::$factory->post->create( array( 'post_content' => $href_with_commentary ) );
     141                $href_with_post_id = self::factory()->post->create( array( 'post_content' => $href_with_commentary ) );
    142142                $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
    143143                $this->assertEquals( $link, $content_link );
    144144
    DATA; 
    148148                $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
    149149                $this->assertEquals( $link, $content_link );
    150150
    151                 $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
     151                $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    152152                $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
    153153                $this->assertEquals( false, $content_link );
    154154
    155                 $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
     155                $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) );
    156156                $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
    157157                $this->assertEquals( false, $content_link );
    158158        }
  • tests/phpunit/tests/post/getBodyClass.php

    diff --git tests/phpunit/tests/post/getBodyClass.php tests/phpunit/tests/post/getBodyClass.php
    index 1592ad1..d7b89e8 100644
    class Tests_Post_GetBodyClass extends WP_UnitTestCase { 
    99
    1010        public function setUp() {
    1111                parent::setUp();
    12                 $this->post_id = self::$factory->post->create();
     12                $this->post_id = self::factory()->post->create();
    1313        }
    1414
    1515        /**
    1616         * @ticket 30883
    1717         */
    1818        public function test_with_utf8_category_slugs() {
    19                 $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) );
    20                 $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) );
    21                 $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) );
     19                $cat_id1 = self::factory()->category->create( array( 'name' => 'Первая рубрика' ) );
     20                $cat_id2 = self::factory()->category->create( array( 'name' => 'Вторая рубрика' ) );
     21                $cat_id3 = self::factory()->category->create( array( 'name' => '25кадр' ) );
    2222                wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' );
    2323
    2424                $this->go_to( home_url( "?cat=$cat_id1" ) );
    class Tests_Post_GetBodyClass extends WP_UnitTestCase { 
    3535         * @ticket 30883
    3636         */
    3737        public function test_with_utf8_tag_slugs() {
    38                 $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) );
    39                 $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) );
    40                 $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) );
     38                $tag_id1 = self::factory()->tag->create( array( 'name' => 'Первая метка' ) );
     39                $tag_id2 = self::factory()->tag->create( array( 'name' => 'Вторая метка' ) );
     40                $tag_id3 = self::factory()->tag->create( array( 'name' => '25кадр' ) );
    4141                wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' );
    4242
    4343                $tag1 = get_term( $tag_id1, 'post_tag' );
    class Tests_Post_GetBodyClass extends WP_UnitTestCase { 
    5959         */
    6060        public function test_with_utf8_term_slugs() {
    6161                register_taxonomy( 'wptests_tax', 'post' );
    62                 $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
    63                 $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
    64                 $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
     62                $term_id1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
     63                $term_id2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
     64                $term_id3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
    6565                wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' );
    6666
    6767                $term1 = get_term( $term_id1, 'wptests_tax' );
  • tests/phpunit/tests/post/getPages.php

    diff --git tests/phpunit/tests/post/getPages.php tests/phpunit/tests/post/getPages.php
    index a9cf113..5391815 100644
    class Tests_Post_getPages extends WP_UnitTestCase { 
    1515        function test_get_pages_cache() {
    1616                global $wpdb;
    1717
    18                 self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
     18                self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) );
    1919                wp_cache_delete( 'last_changed', 'posts' );
    2020                $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
    2121
    class Tests_Post_getPages extends WP_UnitTestCase { 
    9999         * @ticket 20376
    100100         */
    101101        function test_get_pages_meta() {
    102                 $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
     102                $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) );
    103103                add_post_meta( $posts[0], 'some-meta-key', '0' );
    104104                add_post_meta( $posts[1], 'some-meta-key', '' );
    105105                add_post_meta( $posts[2], 'some-meta-key', '1' );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    116116                $page_ids = array();
    117117
    118118                foreach ( range( 1, 20 ) as $i )
    119                         $page_ids[] = self::$factory->post->create( array( 'post_type' => 'page' ) );
     119                        $page_ids[] = self::factory()->post->create( array( 'post_type' => 'page' ) );
    120120
    121121                $inc = array_slice( $page_ids, 0, 10 );
    122122                sort( $inc );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    138138         * @ticket 9470
    139139         */
    140140        function test_get_pages_parent() {
    141                 $page_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    142                 $page_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
    143                 $page_id3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );
    144                 $page_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
     141                $page_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     142                $page_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
     143                $page_id3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );
     144                $page_id4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
    145145
    146146                $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) );
    147147                $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    166166         * @ticket 22389
    167167         */
    168168        function test_wp_dropdown_pages() {
    169                 self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) );
     169                self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) );
    170170
    171171                preg_match_all( '#<option#', wp_dropdown_pages( 'echo=0' ), $matches );
    172172
    class Tests_Post_getPages extends WP_UnitTestCase { 
    177177         * @ticket 22208
    178178         */
    179179        function test_get_chidren_fields_ids() {
    180                 $post_id = self::$factory->post->create();
    181                 $child_ids = self::$factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
     180                $post_id = self::factory()->post->create();
     181                $child_ids = self::factory()->post->create_many( 5, array( 'post_parent' => $post_id ) );
    182182
    183183                $post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) );
    184184                $this->assertEqualSets( $child_ids, $post_ids );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    189189         */
    190190        function test_get_pages_hierarchical_and_no_parent() {
    191191                global $wpdb;
    192                 $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    193                 $page_2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    194                 $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    195                 $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) );
     192                $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     193                $page_2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     194                $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     195                $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) );
    196196
    197197                $pages = get_pages(); // Defaults: hierarchical = true, parent = -1
    198198                $pages_default_args = get_pages( array( 'hierarchical' => true, 'parent' => -1 ) );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    218218         * @ticket 18701
    219219         */
    220220        public function test_get_pages_hierarchical_empty_child_of() {
    221                 $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    222                 $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    223                 $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    224                 $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     221                $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     222                $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     223                $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     224                $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    225225
    226226                $pages = get_pages(); // Defaults: hierarchical = true, child_of = '', parent = -1
    227227                $default_args = get_pages( array(
    class Tests_Post_getPages extends WP_UnitTestCase { 
    252252         * @ticket 18701
    253253         */
    254254        public function test_get_pages_non_hierarchical_empty_child_of() {
    255                 $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    256                 $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    257                 $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    258                 $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     255                $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     256                $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     257                $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     258                $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    259259
    260260                $pages = get_pages( array( 'hierarchical' => false ) ); // child_of = '', parent = -1
    261261
    class Tests_Post_getPages extends WP_UnitTestCase { 
    278278         * @ticket 18701
    279279         */
    280280        public function test_get_pages_hierarchical_non_empty_child_of() {
    281                 $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    282                 $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    283                 $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    284                 $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
    285                 $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     281                $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     282                $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     283                $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     284                $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
     285                $page_5 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    286286
    287287                $pages = get_pages( array( 'child_of' => $page_1 ) ); // Defaults: hierarchical = true, parent = -1.
    288288
    class Tests_Post_getPages extends WP_UnitTestCase { 
    306306         * @ticket 18701
    307307         */
    308308        public function test_get_pages_non_hierarchical_non_empty_child_of() {
    309                 $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    310                 $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    311                 $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    312                 $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
    313                 $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     309                $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     310                $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     311                $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
     312                $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) );
     313                $page_5 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) );
    314314
    315315                $pages = get_pages( array( 'hierarchical' => false, 'child_of' => $page_1 ) );
    316316
    class Tests_Post_getPages extends WP_UnitTestCase { 
    338338                $type = 'taco';
    339339                register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) );
    340340
    341                 $posts = self::$factory->post->create_many( 2, array( 'post_type' => $type ) );
     341                $posts = self::factory()->post->create_many( 2, array( 'post_type' => $type ) );
    342342                $post_id = reset( $posts );
    343343
    344344                $this->go_to( "/?p=$post_id&post_type=$type" );
    class Tests_Post_getPages extends WP_UnitTestCase { 
    360360        }
    361361
    362362        function test_exclude_tree() {
    363                 $post_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    364                 $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) );
    365                 $post_id3 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    366                 $post_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) );
     363                $post_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     364                $post_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) );
     365                $post_id3 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     366                $post_id4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) );
    367367
    368368                $all = get_pages();
    369369
    class Tests_Post_getPages extends WP_UnitTestCase { 
    384384                $exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
    385385                $this->assertCount( 0, $exclude5 );
    386386
    387                 $post_id5 = self::$factory->post->create( array( 'post_type' => 'page' ) );
    388                 $post_id6 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) );
     387                $post_id5 = self::factory()->post->create( array( 'post_type' => 'page' ) );
     388                $post_id6 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) );
    389389
    390390                $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
    391391                $this->assertCount( 2, $exclude6 );
  • tests/phpunit/tests/post/getPostClass.php

    diff --git tests/phpunit/tests/post/getPostClass.php tests/phpunit/tests/post/getPostClass.php
    index 81b96fa..3337114 100644
    class Tests_Post_GetPostClass extends WP_UnitTestCase { 
    99
    1010        public function setUp() {
    1111                parent::setUp();
    12                 $this->post_id = self::$factory->post->create();
     12                $this->post_id = self::factory()->post->create();
    1313        }
    1414
    1515        public function test_with_tags() {
    class Tests_Post_GetPostClass extends WP_UnitTestCase { 
    2222        }
    2323
    2424        public function test_with_categories() {
    25                 $cats = self::$factory->category->create_many( 2 );
     25                $cats = self::factory()->category->create_many( 2 );
    2626                wp_set_post_terms( $this->post_id, $cats, 'category' );
    2727
    2828                $cat0 = get_term( $cats[0], 'category' );
    class Tests_Post_GetPostClass extends WP_UnitTestCase { 
    5757         * @ticket 30883
    5858         */
    5959        public function test_with_utf8_category_slugs() {
    60                 $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) );
    61                 $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) );
    62                 $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) );
     60                $cat_id1 = self::factory()->category->create( array( 'name' => 'Первая рубрика' ) );
     61                $cat_id2 = self::factory()->category->create( array( 'name' => 'Вторая рубрика' ) );
     62                $cat_id3 = self::factory()->category->create( array( 'name' => '25кадр' ) );
    6363                wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' );
    6464
    6565                $found = get_post_class( '', $this->post_id );
    class Tests_Post_GetPostClass extends WP_UnitTestCase { 
    7373         * @ticket 30883
    7474         */
    7575        public function test_with_utf8_tag_slugs() {
    76                 $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) );
    77                 $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) );
    78                 $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) );
     76                $tag_id1 = self::factory()->tag->create( array( 'name' => 'Первая метка' ) );
     77                $tag_id2 = self::factory()->tag->create( array( 'name' => 'Вторая метка' ) );
     78                $tag_id3 = self::factory()->tag->create( array( 'name' => '25кадр' ) );
    7979                wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' );
    8080
    8181                $found = get_post_class( '', $this->post_id );
    class Tests_Post_GetPostClass extends WP_UnitTestCase { 
    9090         */
    9191        public function test_with_utf8_term_slugs() {
    9292                register_taxonomy( 'wptests_tax', 'post' );
    93                 $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
    94                 $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
    95                 $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
     93                $term_id1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) );
     94                $term_id2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) );
     95                $term_id3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) );
    9696                wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' );
    9797
    9898                $found = get_post_class( '', $this->post_id );
  • tests/phpunit/tests/post/getPostsByAuthorSql.php

    diff --git tests/phpunit/tests/post/getPostsByAuthorSql.php tests/phpunit/tests/post/getPostsByAuthorSql.php
    index 0d0ff40..6ae8162 100644
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    5959
    6060        public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user(){
    6161                $current_user = get_current_user_id();
    62                 $u = self::$factory->user->create();
     62                $u = self::factory()->user->create();
    6363                wp_set_current_user( $u );
    6464
    6565                $maybe_string = get_posts_by_author_sql( 'post', true, $u, true );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    7070
    7171        public function test_public_only_should_default_to_false(){
    7272                $current_user = get_current_user_id();
    73                 $u = self::$factory->user->create();
     73                $u = self::factory()->user->create();
    7474                wp_set_current_user( $u );
    7575
    7676                $this->assertSame( get_posts_by_author_sql( 'post', true, $u, false ), get_posts_by_author_sql( 'post', true, $u ) );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    8080
    8181        public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author(){
    8282                $current_user = get_current_user_id();
    83                 $u = self::$factory->user->create();
     83                $u = self::factory()->user->create();
    8484                wp_set_current_user( $u );
    8585
    8686                $maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    9191
    9292        public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author(){
    9393                $current_user = get_current_user_id();
    94                 $u1 = self::$factory->user->create();
    95                 $u2 = self::$factory->user->create();
     94                $u1 = self::factory()->user->create();
     95                $u2 = self::factory()->user->create();
    9696                wp_set_current_user( $u1 );
    9797
    9898                $maybe_string = get_posts_by_author_sql( 'post', true, $u2, false );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    103103
    104104        public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided(){
    105105                $current_user = get_current_user_id();
    106                 $u = self::$factory->user->create();
     106                $u = self::factory()->user->create();
    107107                wp_set_current_user( $u );
    108108
    109109                $maybe_string = get_posts_by_author_sql( 'post', true, $u, false );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    115115
    116116        public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){
    117117                $current_user = get_current_user_id();
    118                 $u = self::$factory->user->create( array( 'role' => 'administrator' ) );
     118                $u = self::factory()->user->create( array( 'role' => 'administrator' ) );
    119119                wp_set_current_user( $u );
    120120
    121121                $maybe_string = get_posts_by_author_sql( 'post', true, null, false );
    class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { 
    130130                register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) );
    131131                register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) );
    132132                $current_user = get_current_user_id();
    133                 $u = self::$factory->user->create( array( 'role' => 'editor' ) );
     133                $u = self::factory()->user->create( array( 'role' => 'editor' ) );
    134134                $editor_role = get_role('editor');
    135135                $editor_role->add_cap( 'read_private_baz' );
    136136                wp_set_current_user( $u );
  • tests/phpunit/tests/post/listPages.php

    diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php
    index 2b89bb2..400d106 100644
    class Tests_List_Pages extends WP_UnitTestCase { 
    2727                global $wpdb;
    2828                $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' );
    2929                $pages = array();
    30                 self::$factory->user->create();
    31                 $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );
    32                 $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );
    33                 $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );
     30                self::factory()->user->create();
     31                $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );
     32                $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );
     33                $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );
    3434
    3535                foreach ( $pages as $page ) {
    36                         $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );
    37                         $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );
    38                         $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );
     36                        $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );
     37                        $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );
     38                        $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );
    3939                }
    4040        }
    4141
  • tests/phpunit/tests/post/meta.php

    diff --git tests/phpunit/tests/post/meta.php tests/phpunit/tests/post/meta.php
    index e4e4d35..7ca095f 100644
    class Tests_Post_Meta extends WP_UnitTestCase { 
    88        function setUp() {
    99                parent::setUp();
    1010
    11                 $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) );
     11                $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) );
    1212
    1313                $post = array(
    1414                        'post_author' => $this->author->ID,
  • tests/phpunit/tests/post/nav-menu.php

    diff --git tests/phpunit/tests/post/nav-menu.php tests/phpunit/tests/post/nav-menu.php
    index 40ac706..5ca95b6 100644
    class Test_Nav_Menus extends WP_UnitTestCase { 
    1616        }
    1717
    1818        function test_wp_get_associated_nav_menu_items() {
    19                 $tag_id = self::$factory->tag->create();
    20                 $cat_id = self::$factory->category->create();
    21                 $post_id = self::$factory->post->create();
    22                 $post_2_id = self::$factory->post->create();
    23                 $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     19                $tag_id = self::factory()->tag->create();
     20                $cat_id = self::factory()->category->create();
     21                $post_id = self::factory()->post->create();
     22                $post_2_id = self::factory()->post->create();
     23                $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    2424
    2525                $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array(
    2626                        'menu-item-type' => 'taxonomy',
    class Test_Nav_Menus extends WP_UnitTestCase { 
    119119
    120120        public function test_wp_get_nav_menu_items_with_taxonomy_term() {
    121121                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    122                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    123                 $child_terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) );
     122                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     123                $child_terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) );
    124124
    125125                $term_menu_item = wp_update_nav_menu_item( $this->menu_id, 0, array(
    126126                        'menu-item-type' => 'taxonomy',
  • tests/phpunit/tests/post/objects.php

    diff --git tests/phpunit/tests/post/objects.php tests/phpunit/tests/post/objects.php
    index 048e6b8..5ad92c6 100644
     
    66class Tests_Post_Objects extends WP_UnitTestCase {
    77
    88        function test_get_post() {
    9                 $id = self::$factory->post->create();
     9                $id = self::factory()->post->create();
    1010
    1111                $post = get_post( $id );
    1212                $this->assertInstanceOf( 'WP_Post', $post );
    class Tests_Post_Objects extends WP_UnitTestCase { 
    6767        }
    6868
    6969        function test_get_post_ancestors() {
    70                 $parent_id = self::$factory->post->create();
    71                 $child_id = self::$factory->post->create();
    72                 $grandchild_id = self::$factory->post->create();
     70                $parent_id = self::factory()->post->create();
     71                $child_id = self::factory()->post->create();
     72                $grandchild_id = self::factory()->post->create();
    7373                $updated = wp_update_post( array( 'ID' => $child_id, 'post_parent' => $parent_id ) );
    7474                $this->assertEquals( $updated, $child_id );
    7575                $updated = wp_update_post( array( 'ID' => $grandchild_id, 'post_parent' => $child_id ) );
    class Tests_Post_Objects extends WP_UnitTestCase { 
    9999        }
    100100
    101101        function test_get_post_category_property() {
    102                 $post_id = self::$factory->post->create();
     102                $post_id = self::factory()->post->create();
    103103                $post = get_post( $post_id );
    104104
    105105                $this->assertInternalType( 'array', $post->post_category );
    class Tests_Post_Objects extends WP_UnitTestCase { 
    118118        }
    119119
    120120        function test_get_tags_input_property() {
    121                 $post_id = self::$factory->post->create();
     121                $post_id = self::factory()->post->create();
    122122                $post = get_post( $post_id );
    123123
    124124                $this->assertInternalType( 'array', $post->tags_input );
    class Tests_Post_Objects extends WP_UnitTestCase { 
    135135        }
    136136
    137137        function test_get_page_template_property() {
    138                 $post_id = self::$factory->post->create();
     138                $post_id = self::factory()->post->create();
    139139                $post = get_post( $post_id );
    140140
    141141                $this->assertInternalType( 'string', $post->page_template );
    class Tests_Post_Objects extends WP_UnitTestCase { 
    155155        }
    156156
    157157        function test_get_post_filter() {
    158                 $post = get_post( self::$factory->post->create( array(
     158                $post = get_post( self::factory()->post->create( array(
    159159                        'post_title' => "Mary's home"
    160160                ) ) );
    161161
    class Tests_Post_Objects extends WP_UnitTestCase { 
    178178        }
    179179
    180180        function test_get_post_identity() {
    181                 $post = get_post( self::$factory->post->create() );
     181                $post = get_post( self::factory()->post->create() );
    182182
    183183                $post->foo = 'bar';
    184184
    class Tests_Post_Objects extends WP_UnitTestCase { 
    187187        }
    188188
    189189        function test_get_post_array() {
    190                 $id = self::$factory->post->create();
     190                $id = self::factory()->post->create();
    191191
    192192                $post = get_post( $id, ARRAY_A );
    193193
    class Tests_Post_Objects extends WP_UnitTestCase { 
    202202        function test_get_post_cache() {
    203203                global $wpdb;
    204204
    205                 $id = self::$factory->post->create();
     205                $id = self::factory()->post->create();
    206206                wp_cache_delete( $id, 'posts' );
    207207
    208208                // get_post( stdClass ) should not prime the cache
  • tests/phpunit/tests/post/output.php

    diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
    index d3c0fb4..52c3eff 100644
    class Tests_Post_Output extends WP_UnitTestCase { 
    4141This is the <b>body</b>.
    4242EOF;
    4343
    44                 $post_id = self::$factory->post->create( compact( 'post_content' ) );
     44                $post_id = self::factory()->post->create( compact( 'post_content' ) );
    4545
    4646                $expected = <<<EOF
    4747<p><i>This is the excerpt.</i><br />
    baz = bar 
    7676
    7777EOF;
    7878
    79                 $post_id = self::$factory->post->create( compact( 'post_content' ) );
     79                $post_id = self::factory()->post->create( compact( 'post_content' ) );
    8080                $this->go_to( get_permalink( $post_id ) );
    8181                $this->assertTrue( is_single() );
    8282                $this->assertTrue( have_posts() );
    EOF; 
    114114
    115115EOF;
    116116
    117                 $post_id = self::$factory->post->create( compact( 'post_content' ) );
     117                $post_id = self::factory()->post->create( compact( 'post_content' ) );
    118118                $this->go_to( get_permalink( $post_id ) );
    119119                $this->assertTrue( is_single() );
    120120                $this->assertTrue( have_posts() );
    EOF; 
    136136<p><span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.aulast=Mariat&amp;rft.aufirst=Denis&amp;rft. au=Denis+Mariat&amp;rft.au=Sead+Taourit&amp;rft.au=G%C3%A9rard+Gu%C3%A9rin&amp; rft.title=Genetics+Selection+Evolution&amp;rft.atitle=&amp;rft.date=2003&amp;rft. volume=35&amp;rft.issue=1&amp;rft.spage=119&amp;rft.epage=133&amp;rft.genre=article&amp; rft.id=info:DOI/10.1051%2Fgse%3A2002039"></span>Mariat, D., Taourit, S., Guérin, G. (2003). . <span style="font-style: italic">Genetics Selection Evolution, 35</span>(1), 119-133. DOI: <a rev="review" href="http://dx.doi.org/10.1051/gse:2002039">10.1051/gse:2002039</a></p>
    137137EOF;
    138138
    139                 $post_id = self::$factory->post->create( compact( 'post_content' ) );
     139                $post_id = self::factory()->post->create( compact( 'post_content' ) );
    140140                $this->go_to( get_permalink( $post_id ) );
    141141                $this->assertTrue( is_single() );
    142142                $this->assertTrue( have_posts() );
    EOF; 
    160160<p><span title="My friends: Alice, Bob and Carol">foo</span></p>
    161161EOF;
    162162
    163                 $post_id = self::$factory->post->create( compact( 'post_content' ) );
     163                $post_id = self::factory()->post->create( compact( 'post_content' ) );
    164164                $this->go_to( get_permalink( $post_id ) );
    165165                $this->assertTrue( is_single() );
    166166                $this->assertTrue( have_posts() );
  • tests/phpunit/tests/post/query.php

    diff --git tests/phpunit/tests/post/query.php tests/phpunit/tests/post/query.php
    index 5b86d21..bc0e865 100644
    class Tests_Post_Query extends WP_UnitTestCase { 
    1111        function test_category__and_var() {
    1212                $q = new WP_Query();
    1313
    14                 $term_id = self::$factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
    15                 $term_id2 = self::$factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
    16                 $post_id = self::$factory->post->create();
     14                $term_id = self::factory()->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
     15                $term_id2 = self::factory()->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
     16                $post_id = self::factory()->post->create();
    1717
    1818                wp_set_post_categories( $post_id, $term_id );
    1919
    class Tests_Post_Query extends WP_UnitTestCase { 
    4141         * @group taxonomy
    4242         */
    4343        function test_empty_category__in() {
    44                 $cat_id = self::$factory->category->create();
    45                 $post_id = self::$factory->post->create();
     44                $cat_id = self::factory()->category->create();
     45                $post_id = self::factory()->post->create();
    4646                wp_set_post_categories( $post_id, $cat_id );
    4747
    4848                $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) );
    class Tests_Post_Query extends WP_UnitTestCase { 
    7171         */
    7272        function test_the_posts_filter() {
    7373                // Create posts and clear their caches.
    74                 $post_ids = self::$factory->post->create_many( 4 );
     74                $post_ids = self::factory()->post->create_many( 4 );
    7575                foreach ( $post_ids as $post_id )
    7676                        clean_post_cache( $post_id );
    7777
    class Tests_Post_Query extends WP_UnitTestCase { 
    115115        }
    116116
    117117        function test_post__in_ordering() {
    118                 $post_id1 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
    119                 $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
    120                 $post_id3 = self::$factory->post->create( array(
     118                $post_id1 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
     119                $post_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
     120                $post_id3 = self::factory()->post->create( array(
    121121                        'post_type' => 'page',
    122122                        'post_parent' => $post_id2,
    123123                        'menu_order' => rand( 1, 100 )
    124124                ) );
    125                 $post_id4 = self::$factory->post->create( array(
     125                $post_id4 = self::factory()->post->create( array(
    126126                        'post_type' => 'page',
    127127                        'post_parent' => $post_id2,
    128128                        'menu_order' => rand( 1, 100 )
    129129                ) );
    130                 $post_id5 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
     130                $post_id5 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) );
    131131
    132132                $ordered = array( $post_id2, $post_id4, $post_id3, $post_id1, $post_id5 );
    133133
    class Tests_Post_Query extends WP_UnitTestCase { 
    140140        }
    141141
    142142        function test_post__in_attachment_ordering() {
    143                 $post_id = self::$factory->post->create();
     143                $post_id = self::factory()->post->create();
    144144                $att_ids = array();
    145145                $file = DIR_TESTDATA . '/images/canola.jpg';
    146                 $att_ids[1] = self::$factory->attachment->create_object( $file, $post_id, array(
     146                $att_ids[1] = self::factory()->attachment->create_object( $file, $post_id, array(
    147147                        'post_mime_type' => 'image/jpeg',
    148148                        'menu_order' => rand( 1, 100 )
    149149                ) );
    150                 $att_ids[2] = self::$factory->attachment->create_object( $file, $post_id, array(
     150                $att_ids[2] = self::factory()->attachment->create_object( $file, $post_id, array(
    151151                        'post_mime_type' => 'image/jpeg',
    152152                        'menu_order' => rand( 1, 100 )
    153153                ) );
    154                 $att_ids[3] = self::$factory->attachment->create_object( $file, $post_id, array(
     154                $att_ids[3] = self::factory()->attachment->create_object( $file, $post_id, array(
    155155                        'post_mime_type' => 'image/jpeg',
    156156                        'menu_order' => rand( 1, 100 )
    157157                ) );
    158                 $att_ids[4] = self::$factory->attachment->create_object( $file, $post_id, array(
     158                $att_ids[4] = self::factory()->attachment->create_object( $file, $post_id, array(
    159159                        'post_mime_type' => 'image/jpeg',
    160160                        'menu_order' => rand( 1, 100 )
    161161                ) );
    162                 $att_ids[5] = self::$factory->attachment->create_object( $file, $post_id, array(
     162                $att_ids[5] = self::factory()->attachment->create_object( $file, $post_id, array(
    163163                        'post_mime_type' => 'image/jpeg',
    164164                        'menu_order' => rand( 1, 100 )
    165165                ) );
    class Tests_Post_Query extends WP_UnitTestCase { 
    311311        public function test_post_name__in() {
    312312                $q = new WP_Query();
    313313
    314                 $post_ids[0] = self::$factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) );
    315                 $post_ids[1] = self::$factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) );
    316                 $post_ids[2] = self::$factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) );
    317                 $post_ids[3] = self::$factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) );
     314                $post_ids[0] = self::factory()->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) );
     315                $post_ids[1] = self::factory()->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) );
     316                $post_ids[2] = self::factory()->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) );
     317                $post_ids[3] = self::factory()->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) );
    318318
    319319                $requested = array( $post_ids[0], $post_ids[3] );
    320320                $q->query( array(
  • tests/phpunit/tests/post/revisions.php

    diff --git tests/phpunit/tests/post/revisions.php tests/phpunit/tests/post/revisions.php
    index aaba1e2..2c97232 100644
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    144144         * @ticket 16847
    145145         */
    146146        function test_revision_view_caps_post() {
    147                 $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
     147                $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
    148148                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    149149
    150150                $revisions = wp_get_post_revisions( $post_id );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    166166         * @ticket 16847
    167167         */
    168168        function test_revision_restore_caps_post() {
    169                 $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
     169                $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
    170170                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    171171
    172172                $revisions = wp_get_post_revisions( $post_id );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    186186         * @ticket 16847
    187187         */
    188188        function test_revision_diff_caps_post() {
    189                 $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
     189                $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) );
    190190                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    191191                wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) );
    192192
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    214214                        'supports' => array( 'revisions' ),
    215215                ) );
    216216
    217                 $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
     217                $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
    218218                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    219219
    220220                $revisions = wp_get_post_revisions( $post_id );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    247247                $editor_user->add_cap( 'edit_published_events' );
    248248
    249249                //create a post as Editor
    250                 $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
     250                $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
    251251                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    252252
    253253                $revisions = wp_get_post_revisions( $post_id );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    282282                $old_id = get_current_user_id();
    283283                wp_set_current_user( self::$editor_user_id );
    284284
    285                 $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) );
     285                $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) );
    286286                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    287287
    288288                $revisions = wp_get_post_revisions( $post_id );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    314314                        'supports' => array( 'revisions' ),
    315315                ) );
    316316
    317                 $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
     317                $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) );
    318318                wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) );
    319319                wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) );
    320320
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    337337        function test_wp_get_post_revisions_should_order_by_post_date() {
    338338                global $wpdb;
    339339
    340                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
     340                $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
    341341
    342342                $post = (array) $post;
    343343                $post_revision_fields = _wp_post_revision_fields( $post );
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    365365         * @ticket 26042
    366366         */
    367367        function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() {
    368                 $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
     368                $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
    369369
    370370                $post = (array) $post;
    371371                $post_revision_fields = _wp_post_revision_fields( $post );
  • tests/phpunit/tests/post/slashes.php

    diff --git tests/phpunit/tests/post/slashes.php tests/phpunit/tests/post/slashes.php
    index 0d3465f..f421141 100644
     
    88class Tests_Post_Slashes extends WP_UnitTestCase {
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     11                $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1212                $this->old_current_user = get_current_user_id();
    1313                wp_set_current_user( $this->author_id );
    1414
    class Tests_Post_Slashes extends WP_UnitTestCase { 
    3333         *
    3434         */
    3535        function test_edit_post() {
    36                 $id = self::$factory->post->create();
     36                $id = self::factory()->post->create();
    3737
    3838                $_POST = array();
    3939                $_POST['post_ID'] = $id;
    class Tests_Post_Slashes extends WP_UnitTestCase { 
    102102         *
    103103         */
    104104        function test_wp_update_post() {
    105                 $id = self::$factory->post->create();
     105                $id = self::factory()->post->create();
    106106
    107107                wp_update_post(array(
    108108                        'ID' => $id,
  • tests/phpunit/tests/post/template.php

    diff --git tests/phpunit/tests/post/template.php tests/phpunit/tests/post/template.php
    index 89b214f..0edf607 100644
    class Tests_Post_Template extends WP_UnitTestCase { 
    88        function test_wp_link_pages() {
    99                $contents = array( 'One', 'Two', 'Three' );
    1010                $content = join( '<!--nextpage-->', $contents );
    11                 $post_id = self::$factory->post->create( array( 'post_content' => $content ) );
     11                $post_id = self::factory()->post->create( array( 'post_content' => $content ) );
    1212
    1313                $this->go_to( '?p=' . $post_id );
    1414
    class Tests_Post_Template extends WP_UnitTestCase { 
    8181                $this->assertEmpty( $none );
    8282
    8383                $bump = '&nbsp;&nbsp;&nbsp;';
    84                 $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
    85                 $child_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) );
    86                 $grandchild_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) );
     84                $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     85                $child_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) );
     86                $grandchild_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) );
    8787
    8888                $title1 = get_post( $page_id )->post_title;
    8989                $title2 = get_post( $child_id )->post_title;
    NO; 
    143143         * @ticket 12494
    144144         */
    145145        public function test_wp_dropdown_pages_value_field_should_default_to_ID() {
    146                 $p = self::$factory->post->create( array(
     146                $p = self::factory()->post->create( array(
    147147                        'post_type' => 'page',
    148148                ) );
    149149
    NO; 
    159159         * @ticket 12494
    160160         */
    161161        public function test_wp_dropdown_pages_value_field_ID() {
    162                 $p = self::$factory->post->create( array(
     162                $p = self::factory()->post->create( array(
    163163                        'post_type' => 'page',
    164164                ) );
    165165
    NO; 
    175175         * @ticket 12494
    176176         */
    177177        public function test_wp_dropdown_pages_value_field_post_name() {
    178                 $p = self::$factory->post->create( array(
     178                $p = self::factory()->post->create( array(
    179179                        'post_type' => 'page',
    180180                        'post_name' => 'foo',
    181181                ) );
    NO; 
    192192         * @ticket 12494
    193193         */
    194194        public function test_wp_dropdown_pages_value_field_should_fall_back_on_ID_when_an_invalid_value_is_provided() {
    195                 $p = self::$factory->post->create( array(
     195                $p = self::factory()->post->create( array(
    196196                        'post_type' => 'page',
    197197                        'post_name' => 'foo',
    198198                ) );
    NO; 
    209209         * @ticket 30082
    210210         */
    211211        public function test_wp_dropdown_pages_should_not_contain_class_attribute_when_no_class_is_passed() {
    212                 $p = self::$factory->post->create( array(
     212                $p = self::factory()->post->create( array(
    213213                        'post_type' => 'page',
    214214                        'post_name' => 'foo',
    215215                ) );
    NO; 
    225225         * @ticket 30082
    226226         */
    227227        public function test_wp_dropdown_pages_should_obey_class_parameter() {
    228                 $p = self::$factory->post->create( array(
     228                $p = self::factory()->post->create( array(
    229229                        'post_type' => 'page',
    230230                        'post_name' => 'foo',
    231231                ) );
    NO; 
    242242         * @ticket 31389
    243243         */
    244244        public function test_get_page_template_slug_by_id() {
    245                 $page_id = self::$factory->post->create( array(
     245                $page_id = self::factory()->post->create( array(
    246246                        'post_type' => 'page',
    247247                ) );
    248248
    NO; 
    259259         * @ticket 31389
    260260         */
    261261        public function test_get_page_template_slug_from_loop() {
    262                 $page_id = self::$factory->post->create( array(
     262                $page_id = self::factory()->post->create( array(
    263263                        'post_type' => 'page',
    264264                ) );
    265265
    NO; 
    273273         * @ticket 31389
    274274         */
    275275        public function test_get_page_template_slug_non_page() {
    276                 $post_id = self::$factory->post->create( array(
     276                $post_id = self::factory()->post->create( array(
    277277                        'post_type' => 'post',
    278278                ) );
    279279
    NO; 
    288288         * @ticket 33974
    289289         */
    290290        public function test_wp_page_menu_wp_nav_menu_fallback() {
    291                 $pages = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) );
     291                $pages = self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) );
    292292
    293293                // No menus + wp_nav_menu() falls back to wp_page_menu().
    294294                $menu = wp_nav_menu( array( 'echo' => false ) );
  • tests/phpunit/tests/post/wpUniquePostSlug.php

    diff --git tests/phpunit/tests/post/wpUniquePostSlug.php tests/phpunit/tests/post/wpUniquePostSlug.php
    index 2f7f013..690fc3e 100644
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    88         * @ticket 21013
    99         */
    1010        public function test_non_latin_slugs() {
    11                 $author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     11                $author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1212
    1313                $inputs = array(
    1414                        'Αρνάκι άσπρο και παχύ της μάνας του καμάρι, και άλλα τραγούδια',
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    4949                        'post_name' => 'some-slug',
    5050                        'post_status' => 'publish',
    5151                );
    52                 $one = self::$factory->post->create( $args );
     52                $one = self::factory()->post->create( $args );
    5353                $args['post_type'] = 'post-type-2';
    54                 $two = self::$factory->post->create( $args );
     54                $two = self::factory()->post->create( $args );
    5555
    5656                $this->assertEquals( 'some-slug', get_post( $one )->post_name );
    5757                $this->assertEquals( 'some-slug', get_post( $two )->post_name );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    7474                        'post_name' => 'some-slug',
    7575                        'post_status' => 'publish',
    7676                );
    77                 $one = self::$factory->post->create( $args );
     77                $one = self::factory()->post->create( $args );
    7878                $args['post_name'] = 'some-slug-2';
    79                 $two = self::$factory->post->create( $args );
     79                $two = self::factory()->post->create( $args );
    8080
    8181                $this->assertEquals( 'some-slug', get_post( $one )->post_name );
    8282                $this->assertEquals( 'some-slug-2', get_post( $two )->post_name );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    9797                        'post_name' => 'some-slug',
    9898                        'post_status' => 'publish',
    9999                );
    100                 $one = self::$factory->post->create( $args );
     100                $one = self::factory()->post->create( $args );
    101101
    102102                $args = array(
    103103                        'post_mime_type' => 'image/jpeg',
    104104                        'post_type' => 'attachment',
    105105                        'post_name' => 'image'
    106106                );
    107                 $attachment = self::$factory->attachment->create_object( 'image.jpg', $one, $args );
     107                $attachment = self::factory()->attachment->create_object( 'image.jpg', $one, $args );
    108108
    109109                $args = array(
    110110                        'post_type' => 'post-type-1',
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    112112                        'post_status' => 'publish',
    113113                        'post_parent' => $one
    114114                );
    115                 $two = self::$factory->post->create( $args );
     115                $two = self::factory()->post->create( $args );
    116116
    117117                $this->assertEquals( 'some-slug', get_post( $one )->post_name );
    118118                $this->assertEquals( 'image', get_post( $attachment )->post_name );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    128128         * @dataProvider whitelist_post_statuses
    129129         */
    130130        public function test_whitelisted_post_statuses_should_not_be_forced_to_be_unique( $status ) {
    131                 $p1 = self::$factory->post->create( array(
     131                $p1 = self::factory()->post->create( array(
    132132                        'post_type' => 'post',
    133133                        'post_name' => 'foo',
    134134                ) );
    135135
    136                 $p2 = self::$factory->post->create( array(
     136                $p2 = self::factory()->post->create( array(
    137137                        'post_type' => 'post',
    138138                ) );
    139139
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    151151        }
    152152
    153153        public function test_revisions_should_not_be_forced_to_be_unique() {
    154                 $p1 = self::$factory->post->create( array(
     154                $p1 = self::factory()->post->create( array(
    155155                        'post_type' => 'post',
    156156                        'post_name' => 'foo',
    157157                ) );
    158158
    159                 $p2 = self::$factory->post->create( array(
     159                $p2 = self::factory()->post->create( array(
    160160                        'post_type' => 'post',
    161161                ) );
    162162
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    171171        public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() {
    172172                $this->set_permalink_structure( '/%postname%/' );
    173173
    174                 $p = self::$factory->post->create( array(
     174                $p = self::factory()->post->create( array(
    175175                        'post_type' => 'post',
    176176                        'post_name' => 'foo',
    177177                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    186186        public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() {
    187187                $this->set_permalink_structure( '/%postname%/' );
    188188
    189                 $p = self::$factory->post->create( array(
     189                $p = self::factory()->post->create( array(
    190190                        'post_type' => 'post',
    191191                        'post_name' => 'foo',
    192192                        'post_status' => 'publish',
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    202202        public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() {
    203203                $this->set_permalink_structure( '/%year%/%postname%/' );
    204204
    205                 $p = self::$factory->post->create( array(
     205                $p = self::factory()->post->create( array(
    206206                        'post_type' => 'post',
    207207                        'post_name' => 'foo',
    208208                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    217217        public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() {
    218218                $this->set_permalink_structure( '/%year%/%postname%/' );
    219219
    220                 $p = self::$factory->post->create( array(
     220                $p = self::factory()->post->create( array(
    221221                        'post_type' => 'post',
    222222                        'post_name' => 'foo',
    223223                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    232232        public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() {
    233233                $this->set_permalink_structure( '/%year%/foo/%postname%/' );
    234234
    235                 $p = self::$factory->post->create( array(
     235                $p = self::factory()->post->create( array(
    236236                        'post_type' => 'post',
    237237                        'post_name' => 'foo',
    238238                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    247247        public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() {
    248248                $this->set_permalink_structure( '/%year%/%postname%/' );
    249249
    250                 $p = self::$factory->post->create( array(
     250                $p = self::factory()->post->create( array(
    251251                        'post_type' => 'post',
    252252                        'post_name' => 'foo',
    253253                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    262262        public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() {
    263263                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    264264
    265                 $p = self::$factory->post->create( array(
     265                $p = self::factory()->post->create( array(
    266266                        'post_type' => 'post',
    267267                        'post_name' => 'foo',
    268268                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    277277        public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() {
    278278                $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    279279
    280                 $p = self::$factory->post->create( array(
     280                $p = self::factory()->post->create( array(
    281281                        'post_type' => 'post',
    282282                        'post_name' => 'foo',
    283283                ) );
    class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { 
    292292        public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() {
    293293                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    294294
    295                 $p = self::$factory->post->create( array(
     295                $p = self::factory()->post->create( array(
    296296                        'post_type' => 'post',
    297297                        'post_name' => 'foo',
    298298                ) );
  • tests/phpunit/tests/query.php

    diff --git tests/phpunit/tests/query.php tests/phpunit/tests/query.php
    index 1bcf175..b5ab027 100644
    class Tests_Query extends WP_UnitTestCase { 
    1414         *
    1515         */
    1616        function test_nested_loop_reset_postdata() {
    17                 $post_id = self::$factory->post->create();
    18                 $nested_post_id = self::$factory->post->create();
     17                $post_id = self::factory()->post->create();
     18                $nested_post_id = self::factory()->post->create();
    1919
    2020                $first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) );
    2121                while ( $first_query->have_posts() ) { $first_query->the_post();
    class Tests_Query extends WP_UnitTestCase { 
    4343         * @ticket 25380
    4444         */
    4545        function test_pre_posts_per_page() {
    46                 self::$factory->post->create_many( 10 );
     46                self::factory()->post->create_many( 10 );
    4747
    4848                add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) );
    4949
    class Tests_Query extends WP_UnitTestCase { 
    6161         */
    6262        function test_tag_queried_object() {
    6363                $slug = 'tag-slug-26627';
    64                 self::$factory->tag->create( array( 'slug' => $slug ) );
     64                self::factory()->tag->create( array( 'slug' => $slug ) );
    6565                $tag = get_term_by( 'slug', $slug, 'post_tag' );
    6666
    6767                add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
    class Tests_Query extends WP_UnitTestCase { 
    9494                // Don't override the args provided below.
    9595                remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
    9696                register_taxonomy( 'wptests_tax', 'post' );
    97                 $terms = self::$factory->term->create_many( 2, array(
     97                $terms = self::factory()->term->create_many( 2, array(
    9898                        'taxonomy' => 'wptests_tax',
    9999                ) );
    100100
    101                 $posts = self::$factory->post->create_many( 2 );
     101                $posts = self::factory()->post->create_many( 2 );
    102102
    103103                wp_set_object_terms( $posts[0], array( $terms[0] ), 'wptests_tax' );
    104104                wp_set_object_terms( $posts[1], array( $terms[1] ), 'wptests_tax' );
    class Tests_Query extends WP_UnitTestCase { 
    130130        }
    131131
    132132        public function test_cat_querystring_single_term() {
    133                 $c1 = self::$factory->category->create( array(
     133                $c1 = self::factory()->category->create( array(
    134134                        'name' => 'Test Category 1',
    135135                        'slug' => 'test1',
    136136                ) );
    137                 $c2 = self::$factory->category->create( array(
     137                $c2 = self::factory()->category->create( array(
    138138                        'name' => 'Test Category 2',
    139139                        'slug' => 'test2',
    140140                ) );
    141141
    142                 $p1 = self::$factory->post->create();
    143                 $p2 = self::$factory->post->create();
    144                 $p3 = self::$factory->post->create();
     142                $p1 = self::factory()->post->create();
     143                $p2 = self::factory()->post->create();
     144                $p3 = self::factory()->post->create();
    145145
    146146                wp_set_object_terms( $p1, $c1, 'category' );
    147147                wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
    class Tests_Query extends WP_UnitTestCase { 
    159159        }
    160160
    161161        public function test_category_querystring_multiple_terms_comma_separated() {
    162                 $c1 = self::$factory->category->create( array(
     162                $c1 = self::factory()->category->create( array(
    163163                        'name' => 'Test Category 1',
    164164                        'slug' => 'test1',
    165165                ) );
    166                 $c2 = self::$factory->category->create( array(
     166                $c2 = self::factory()->category->create( array(
    167167                        'name' => 'Test Category 2',
    168168                        'slug' => 'test2',
    169169                ) );
    170                 $c3 = self::$factory->category->create( array(
     170                $c3 = self::factory()->category->create( array(
    171171                        'name' => 'Test Category 3',
    172172                        'slug' => 'test3',
    173173                ) );
    174174
    175                 $p1 = self::$factory->post->create();
    176                 $p2 = self::$factory->post->create();
    177                 $p3 = self::$factory->post->create();
    178                 $p4 = self::$factory->post->create();
     175                $p1 = self::factory()->post->create();
     176                $p2 = self::factory()->post->create();
     177                $p3 = self::factory()->post->create();
     178                $p4 = self::factory()->post->create();
    179179
    180180                wp_set_object_terms( $p1, $c1, 'category' );
    181181                wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
    class Tests_Query extends WP_UnitTestCase { 
    197197         * @ticket 33532
    198198         */
    199199        public function test_category_querystring_multiple_terms_formatted_as_array() {
    200                 $c1 = self::$factory->category->create( array(
     200                $c1 = self::factory()->category->create( array(
    201201                        'name' => 'Test Category 1',
    202202                        'slug' => 'test1',
    203203                ) );
    204                 $c2 = self::$factory->category->create( array(
     204                $c2 = self::factory()->category->create( array(
    205205                        'name' => 'Test Category 2',
    206206                        'slug' => 'test2',
    207207                ) );
    208                 $c3 = self::$factory->category->create( array(
     208                $c3 = self::factory()->category->create( array(
    209209                        'name' => 'Test Category 3',
    210210                        'slug' => 'test3',
    211211                ) );
    212212
    213                 $p1 = self::$factory->post->create();
    214                 $p2 = self::$factory->post->create();
    215                 $p3 = self::$factory->post->create();
    216                 $p4 = self::$factory->post->create();
     213                $p1 = self::factory()->post->create();
     214                $p2 = self::factory()->post->create();
     215                $p3 = self::factory()->post->create();
     216                $p4 = self::factory()->post->create();
    217217
    218218                wp_set_object_terms( $p1, $c1, 'category' );
    219219                wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' );
    class Tests_Query extends WP_UnitTestCase { 
    233233
    234234
    235235        public function test_tag_querystring_single_term() {
    236                 $t1 = self::$factory->tag->create_and_get( array(
     236                $t1 = self::factory()->tag->create_and_get( array(
    237237                        'name' => 'Test Tag 1',
    238238                        'slug' => 'test1',
    239239                ) );
    240                 $t2 = self::$factory->tag->create_and_get( array(
     240                $t2 = self::factory()->tag->create_and_get( array(
    241241                        'name' => 'Test Tag 2',
    242242                        'slug' => 'test2',
    243243                ) );
    244244
    245                 $p1 = self::$factory->post->create();
    246                 $p2 = self::$factory->post->create();
    247                 $p3 = self::$factory->post->create();
     245                $p1 = self::factory()->post->create();
     246                $p2 = self::factory()->post->create();
     247                $p3 = self::factory()->post->create();
    248248
    249249                wp_set_object_terms( $p1, $t1->slug, 'post_tag' );
    250250                wp_set_object_terms( $p2, array( $t1->slug, $t2->slug ), 'post_tag' );
    class Tests_Query extends WP_UnitTestCase { 
    262262        }
    263263
    264264        public function test_tag_querystring_multiple_terms_comma_separated() {
    265                 $c1 = self::$factory->tag->create_and_get( array(
     265                $c1 = self::factory()->tag->create_and_get( array(
    266266                        'name' => 'Test Tag 1',
    267267                        'slug' => 'test1',
    268268                ) );
    269                 $c2 = self::$factory->tag->create_and_get( array(
     269                $c2 = self::factory()->tag->create_and_get( array(
    270270                        'name' => 'Test Tag 2',
    271271                        'slug' => 'test2',
    272272                ) );
    273                 $c3 = self::$factory->tag->create_and_get( array(
     273                $c3 = self::factory()->tag->create_and_get( array(
    274274                        'name' => 'Test Tag 3',
    275275                        'slug' => 'test3',
    276276                ) );
    277277
    278                 $p1 = self::$factory->post->create();
    279                 $p2 = self::$factory->post->create();
    280                 $p3 = self::$factory->post->create();
    281                 $p4 = self::$factory->post->create();
     278                $p1 = self::factory()->post->create();
     279                $p2 = self::factory()->post->create();
     280                $p3 = self::factory()->post->create();
     281                $p4 = self::factory()->post->create();
    282282
    283283                wp_set_object_terms( $p1, $c1->slug, 'post_tag' );
    284284                wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' );
    class Tests_Query extends WP_UnitTestCase { 
    300300         * @ticket 33532
    301301         */
    302302        public function test_tag_querystring_multiple_terms_formatted_as_array() {
    303                 $c1 = self::$factory->tag->create_and_get( array(
     303                $c1 = self::factory()->tag->create_and_get( array(
    304304                        'name' => 'Test Tag 1',
    305305                        'slug' => 'test1',
    306306                ) );
    307                 $c2 = self::$factory->tag->create_and_get( array(
     307                $c2 = self::factory()->tag->create_and_get( array(
    308308                        'name' => 'Test Tag 2',
    309309                        'slug' => 'test2',
    310310                ) );
    311                 $c3 = self::$factory->tag->create_and_get( array(
     311                $c3 = self::factory()->tag->create_and_get( array(
    312312                        'name' => 'Test Tag 3',
    313313                        'slug' => 'test3',
    314314                ) );
    315315
    316                 $p1 = self::$factory->post->create();
    317                 $p2 = self::$factory->post->create();
    318                 $p3 = self::$factory->post->create();
    319                 $p4 = self::$factory->post->create();
     316                $p1 = self::factory()->post->create();
     317                $p2 = self::factory()->post->create();
     318                $p3 = self::factory()->post->create();
     319                $p4 = self::factory()->post->create();
    320320
    321321                wp_set_object_terms( $p1, $c1->slug, 'post_tag' );
    322322                wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' );
    class Tests_Query extends WP_UnitTestCase { 
    341341                wp_insert_term( 'test2', 'test_tax_cat' );
    342342                wp_insert_term( 'test3', 'test_tax_cat' );
    343343
    344                 $p1 = self::$factory->post->create();
    345                 $p2 = self::$factory->post->create();
    346                 $p3 = self::$factory->post->create();
     344                $p1 = self::factory()->post->create();
     345                $p2 = self::factory()->post->create();
     346                $p3 = self::factory()->post->create();
    347347
    348348                wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
    349349                wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
    class Tests_Query extends WP_UnitTestCase { 
    365365                wp_insert_term( 'test2', 'test_tax_cat' );
    366366                wp_insert_term( 'test3', 'test_tax_cat' );
    367367
    368                 $p1 = self::$factory->post->create();
    369                 $p2 = self::$factory->post->create();
    370                 $p3 = self::$factory->post->create();
    371                 $p4 = self::$factory->post->create();
     368                $p1 = self::factory()->post->create();
     369                $p2 = self::factory()->post->create();
     370                $p3 = self::factory()->post->create();
     371                $p4 = self::factory()->post->create();
    372372
    373373                wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
    374374                wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
    class Tests_Query extends WP_UnitTestCase { 
    394394                wp_insert_term( 'test2', 'test_tax_cat' );
    395395                wp_insert_term( 'test3', 'test_tax_cat' );
    396396
    397                 $p1 = self::$factory->post->create();
    398                 $p2 = self::$factory->post->create();
    399                 $p3 = self::$factory->post->create();
    400                 $p4 = self::$factory->post->create();
     397                $p1 = self::factory()->post->create();
     398                $p2 = self::factory()->post->create();
     399                $p3 = self::factory()->post->create();
     400                $p4 = self::factory()->post->create();
    401401
    402402                wp_set_object_terms( $p1, 'test1', 'test_tax_cat' );
    403403                wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' );
    class Tests_Query extends WP_UnitTestCase { 
    417417         * @ticket 31355
    418418         */
    419419        public function test_pages_dont_404_when_queried_post_id_is_modified() {
    420                 $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) );
     420                $post_id = self::factory()->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) );
    421421
    422422                add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );
    423423
    class Tests_Query extends WP_UnitTestCase { 
    438438
    439439                register_post_type( 'guide', array( 'name' => 'Guide', 'public' => true, 'hierarchical' => true ) );
    440440                $wp_rewrite->flush_rules();
    441                 $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) );
     441                $post_id = self::factory()->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) );
    442442
    443443                add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) );
    444444
  • tests/phpunit/tests/query/conditionals.php

    diff --git tests/phpunit/tests/query/conditionals.php tests/phpunit/tests/query/conditionals.php
    index c645a46..8a351e7 100644
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    4545        }
    4646
    4747        function test_permalink() {
    48                 $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
     48                $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    4949                $this->go_to( get_permalink( $post_id ) );
    5050                $this->assertQueryTrue('is_single', 'is_singular');
    5151        }
    5252
    5353        function test_post_comments_feed() {
    54                 $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
    55                 self::$factory->comment->create_post_comments( $post_id, 2 );
     54                $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
     55                self::factory()->comment->create_post_comments( $post_id, 2 );
    5656                $this->go_to( get_post_comments_feed_link( $post_id ) );
    5757                $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
    5858        }
    5959
    6060
    6161        function test_post_comments_feed_with_no_comments() {
    62                 $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
     62                $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
    6363                $this->go_to( get_post_comments_feed_link( $post_id ) );
    6464                $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
    6565        }
    6666
    6767        function test_page() {
    68                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
     68                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
    6969                $this->go_to( get_permalink( $page_id ) );
    7070                $this->assertQueryTrue('is_page','is_singular');
    7171        }
    7272
    7373        function test_parent_page() {
    74                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     74                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    7575                $this->go_to( get_permalink( $page_id ) );
    7676
    7777                $this->assertQueryTrue('is_page','is_singular');
    7878        }
    7979
    8080        function test_child_page_1() {
    81                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    82                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     81                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     82                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    8383                $this->go_to( get_permalink( $page_id ) );
    8484
    8585                $this->assertQueryTrue('is_page','is_singular');
    8686        }
    8787
    8888        function test_child_page_2() {
    89                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    90                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    91                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     89                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     90                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     91                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    9292                $this->go_to( get_permalink( $page_id ) );
    9393
    9494                $this->assertQueryTrue('is_page','is_singular');
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    9797        // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1'
    9898        function test_page_trackback() {
    9999                $page_ids = array();
    100                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    101                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    102                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     100                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     101                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     102                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    103103                foreach ( $page_ids as $page_id ) {
    104104                        $url = get_permalink( $page_id );
    105105                        $this->go_to("{$url}trackback/");
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    116116        //'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
    117117        function test_page_feed() {
    118118                $page_ids = array();
    119                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    120                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    121                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     119                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     120                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     121                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    122122                foreach ( $page_ids as $page_id ) {
    123                         self::$factory->comment->create_post_comments( $page_id, 2 );
     123                        self::factory()->comment->create_post_comments( $page_id, 2 );
    124124                        $url = get_permalink( $page_id );
    125125                        $this->go_to("{$url}feed/");
    126126
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    135135
    136136        function test_page_feed_with_no_comments() {
    137137                $page_ids = array();
    138                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    139                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    140                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     138                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     139                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     140                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    141141                foreach ( $page_ids as $page_id ) {
    142142                        $url = get_permalink( $page_id );
    143143                        $this->go_to("{$url}feed/");
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    154154        // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
    155155        function test_page_feed_atom() {
    156156                $page_ids = array();
    157                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
    158                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
    159                 $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
     157                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
     158                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
     159                $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
    160160                foreach ( $page_ids as $page_id ) {
    161                         self::$factory->comment->create_post_comments( $page_id, 2 );
     161                        self::factory()->comment->create_post_comments( $page_id, 2 );
    162162
    163163                        $url = get_permalink( $page_id );
    164164                        $this->go_to("{$url}feed/atom/");
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    174174
    175175        // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
    176176        function test_page_page_2() {
    177                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
     177                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
    178178                $this->go_to("/about/page/2/");
    179179
    180180                // make sure the correct wp_query flags are set
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    187187
    188188        // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
    189189        function test_page_page_2_no_slash() {
    190                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
     190                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
    191191                $this->go_to("/about/page2/");
    192192
    193193                // make sure the correct wp_query flags are set
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    201201        // FIXME: what is this for?
    202202        // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
    203203        function test_pagination_of_posts_page() {
    204                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
     204                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
    205205                update_option( 'show_on_front', 'page' );
    206206                update_option( 'page_for_posts', $page_id );
    207207
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    223223        // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
    224224        // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
    225225        function test_main_feed_2() {
    226                 self::$factory->post->create(); // @test_404
     226                self::factory()->post->create(); // @test_404
    227227                $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    228228
    229229                // long version
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    241241        }
    242242
    243243        function test_main_feed() {
    244                 self::$factory->post->create(); // @test_404
     244                self::factory()->post->create(); // @test_404
    245245                $types = array('rss2', 'rss', 'atom');
    246246                foreach ($types as $type) {
    247247                        $this->go_to(get_feed_link($type));
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    252252        // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
    253253        function test_paged() {
    254254                update_option( 'posts_per_page', 2 );
    255                 self::$factory->post->create_many( 5 );
     255                self::factory()->post->create_many( 5 );
    256256                for ( $i = 2; $i <= 3; $i++ ) {
    257257                        $this->go_to("/page/{$i}/");
    258258                        $this->assertQueryTrue('is_home', 'is_paged');
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    262262        // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
    263263        // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
    264264        function test_main_comments_feed() {
    265                 $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
    266                 self::$factory->comment->create_post_comments( $post_id, 2 );
     265                $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) );
     266                self::factory()->comment->create_post_comments( $post_id, 2 );
    267267
    268268                // check the url as generated by get_post_comments_feed_link()
    269269                $this->go_to( get_post_comments_feed_link( $post_id ) );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    306306        // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
    307307        function test_search_paged() {
    308308                update_option( 'posts_per_page', 2 );
    309                 self::$factory->post->create_many( 3, array( 'post_title' => 'test' ) );
     309                self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) );
    310310                $this->go_to('/search/test/page/2/');
    311311                $this->assertQueryTrue('is_search', 'is_paged');
    312312        }
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    328328        // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
    329329        // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
    330330        function test_category_feed() {
    331                 self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
     331                self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
    332332                // check the long form
    333333                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    334334                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    347347        // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
    348348        function test_category_paged() {
    349349                update_option( 'posts_per_page', 2 );
    350                 self::$factory->post->create_many( 3 );
     350                self::factory()->post->create_many( 3 );
    351351                $this->go_to('/category/uncategorized/page/2/');
    352352                $this->assertQueryTrue('is_archive', 'is_category', 'is_paged');
    353353        }
    354354
    355355        // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
    356356        function test_category() {
    357                 self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
     357                self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
    358358                $this->go_to('/category/cat-a/');
    359359                $this->assertQueryTrue('is_archive', 'is_category');
    360360        }
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    362362        // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
    363363        // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
    364364        function test_tag_feed() {
    365                 self::$factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
     365                self::factory()->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
    366366                // check the long form
    367367                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    368368                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    381381        // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
    382382        function test_tag_paged() {
    383383                update_option( 'posts_per_page', 2 );
    384                 $post_ids = self::$factory->post->create_many( 3 );
     384                $post_ids = self::factory()->post->create_many( 3 );
    385385                foreach ( $post_ids as $post_id )
    386                         self::$factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
     386                        self::factory()->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
    387387                $this->go_to('/tag/tag-a/page/2/');
    388388                $this->assertQueryTrue('is_archive', 'is_tag', 'is_paged');
    389389        }
    390390
    391391        // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
    392392        function test_tag() {
    393                 $term_id = self::$factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
     393                $term_id = self::factory()->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
    394394                $this->go_to('/tag/tag-a/');
    395395                $this->assertQueryTrue('is_archive', 'is_tag');
    396396
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    409409        // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
    410410        // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
    411411        function test_author_feed() {
    412                 self::$factory->user->create( array( 'user_login' => 'user-a' ) );
     412                self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    413413                // check the long form
    414414                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    415415                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    428428        // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
    429429        function test_author_paged() {
    430430                update_option( 'posts_per_page', 2 );
    431                 $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
    432                 self::$factory->post->create_many( 3, array( 'post_author' => $user_id ) );
     431                $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
     432                self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) );
    433433                $this->go_to('/author/user-a/page/2/');
    434434                $this->assertQueryTrue('is_archive', 'is_author', 'is_paged');
    435435        }
    436436
    437437        // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
    438438        function test_author() {
    439                 $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
    440                 self::$factory->post->create( array( 'post_author' => $user_id ) );
     439                $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
     440                self::factory()->post->create( array( 'post_author' => $user_id ) );
    441441                $this->go_to('/author/user-a/');
    442442                $this->assertQueryTrue('is_archive', 'is_author');
    443443        }
    444444
    445445        function test_author_with_no_posts() {
    446                 $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
     446                $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    447447                $this->go_to('/author/user-a/');
    448448                $this->assertQueryTrue('is_archive', 'is_author');
    449449        }
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    451451        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
    452452        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
    453453        function test_ymd_feed() {
    454                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     454                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    455455                // check the long form
    456456                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    457457                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    470470        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]',
    471471        function test_ymd_paged() {
    472472                update_option( 'posts_per_page', 2 );
    473                 self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     473                self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
    474474                $this->go_to('/2007/09/04/page/2/');
    475475                $this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged');
    476476        }
    477477
    478478        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
    479479        function test_ymd() {
    480                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     480                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    481481                $this->go_to('/2007/09/04/');
    482482                $this->assertQueryTrue('is_archive', 'is_day', 'is_date');
    483483        }
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    485485        // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
    486486        // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
    487487        function test_ym_feed() {
    488                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     488                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    489489                // check the long form
    490490                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    491491                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    504504        // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
    505505        function test_ym_paged() {
    506506                update_option( 'posts_per_page', 2 );
    507                 self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     507                self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
    508508                $this->go_to('/2007/09/page/2/');
    509509                $this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged');
    510510        }
    511511
    512512        // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
    513513        function test_ym() {
    514                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     514                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    515515                $this->go_to('/2007/09/');
    516516                $this->assertQueryTrue('is_archive', 'is_date', 'is_month');
    517517        }
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    519519        // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
    520520        // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
    521521        function test_y_feed() {
    522                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     522                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    523523                // check the long form
    524524                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    525525                foreach ($types as $type) {
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    538538        // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
    539539        function test_y_paged() {
    540540                update_option( 'posts_per_page', 2 );
    541                 self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
     541                self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
    542542                $this->go_to('/2007/page/2/');
    543543                $this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged');
    544544        }
    545545
    546546        // '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
    547547        function test_y() {
    548                 self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
     548                self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
    549549                $this->go_to('/2007/');
    550550                $this->assertQueryTrue('is_archive', 'is_date', 'is_year');
    551551        }
    552552
    553553        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1',
    554554        function test_post_trackback() {
    555                 $post_id = self::$factory->post->create();
     555                $post_id = self::factory()->post->create();
    556556                $permalink = get_permalink( $post_id );
    557557                $this->go_to("{$permalink}trackback/");
    558558                $this->assertQueryTrue('is_single', 'is_singular', 'is_trackback');
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    561561        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
    562562        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]',
    563563        function test_post_comment_feed() {
    564                 $post_id = self::$factory->post->create();
     564                $post_id = self::factory()->post->create();
    565565                $permalink = get_permalink( $post_id );
    566566
    567567                $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    580580
    581581        // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]',
    582582        function test_post_paged_short() {
    583                 $post_id = self::$factory->post->create( array(
     583                $post_id = self::factory()->post->create( array(
    584584                        'post_date' => '2007-09-04 00:00:00',
    585585                        'post_title' => 'a-post-with-multiple-pages',
    586586                        'post_content' => 'Page 1 <!--nextpage--> Page 2'
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    593593
    594594        // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
    595595        function test_post_attachment() {
    596                 $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
     596                $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    597597                $permalink = get_attachment_link( $post_id );
    598598                $this->go_to($permalink);
    599599                $this->assertQueryTrue('is_single', 'is_attachment', 'is_singular');
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    629629                        'public' => true
    630630                ) );
    631631
    632                 $tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) );
    633                 $post_id = self::$factory->post->create( array( 'post_type' => $cpt_name ) );
     632                $tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) );
     633                $post_id = self::factory()->post->create( array( 'post_type' => $cpt_name ) );
    634634                wp_set_object_terms( $post_id, $tag_id, 'post_tag' );
    635635
    636636                $this->go_to( '/ptawtq/' );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    663663                        'has_archive' => true,
    664664                        'public' => true
    665665                ) );
    666                 self::$factory->post->create( array( 'post_type' => $cpt_name ) );
     666                self::factory()->post->create( array( 'post_type' => $cpt_name ) );
    667667
    668668                $this->go_to( "/$cpt_name/" );
    669669                $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    683683        }
    684684
    685685        function test_is_single() {
    686                 $post_id = self::$factory->post->create();
     686                $post_id = self::factory()->post->create();
    687687                $this->go_to( "/?p=$post_id" );
    688688
    689689                $post = get_queried_object();
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    714714                ) );
    715715
    716716                // Create parent and child posts
    717                 $parent_id = self::$factory->post->create( array(
     717                $parent_id = self::factory()->post->create( array(
    718718                        'post_type' => $post_type,
    719719                        'post_name' => 'foo'
    720720                ) );
    721721
    722                 $post_id = self::$factory->post->create( array(
     722                $post_id = self::factory()->post->create( array(
    723723                        'post_type'   => $post_type,
    724724                        'post_name'   => 'bar',
    725725                        'post_parent' => $parent_id
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    750750         * @ticket 24674
    751751         */
    752752        public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_with_another_post_id() {
    753                 $p1 = self::$factory->post->create();
     753                $p1 = self::factory()->post->create();
    754754
    755755                $p2_name = $p1 . '-post';
    756                 $p2 = self::$factory->post->create( array(
     756                $p2 = self::factory()->post->create( array(
    757757                        'slug' => $p2_name,
    758758                ) );
    759759
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    768768        }
    769769
    770770        function test_is_page() {
    771                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     771                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    772772                $this->go_to( "/?page_id=$post_id" );
    773773
    774774                $post = get_queried_object();
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    788788         * @ticket 16802
    789789         */
    790790        function test_is_page_with_parent() {
    791                 $parent_id = self::$factory->post->create( array(
     791                $parent_id = self::factory()->post->create( array(
    792792                        'post_type' => 'page',
    793793                        'post_name' => 'foo',
    794794                ) );
    795                 $post_id = self::$factory->post->create( array(
     795                $post_id = self::factory()->post->create( array(
    796796                        'post_type'   => 'page',
    797797                        'post_name'   => 'bar',
    798798                        'post_parent' => $parent_id,
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    818818        }
    819819
    820820        function test_is_attachment() {
    821                 $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
     821                $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    822822                $this->go_to( "/?attachment_id=$post_id" );
    823823
    824824                $post = get_queried_object();
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    839839         * @ticket 24674
    840840         */
    841841        public function test_is_attachment_with_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
    842                 $p1 = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
     842                $p1 = self::factory()->post->create( array( 'post_type' => 'attachment' ) );
    843843
    844844                $p2_name = $p1 . '-attachment';
    845                 $p2 = self::$factory->post->create( array(
     845                $p2 = self::factory()->post->create( array(
    846846                        'post_type' => 'attachment',
    847847                        'post_name' => $p2_name,
    848848                ) );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    861861         * @ticket 24674
    862862         */
    863863        public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() {
    864                 $u1 = self::$factory->user->create();
     864                $u1 = self::factory()->user->create();
    865865
    866866                $u2_name = $u1 . '_user';
    867                 $u2 = self::$factory->user->create( array(
     867                $u2 = self::factory()->user->create( array(
    868868                        'user_nicename' => $u2_name,
    869869                ) );
    870870
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    882882         * @ticket 24674
    883883         */
    884884        public function test_is_category_with_slug_that_begins_with_a_number_that_clashes_with_another_category_id() {
    885                 $c1 = self::$factory->category->create();
     885                $c1 = self::factory()->category->create();
    886886
    887887                $c2_name = $c1 . '-category';
    888                 $c2 = self::$factory->category->create( array(
     888                $c2 = self::factory()->category->create( array(
    889889                        'slug' => $c2_name,
    890890                ) );
    891891
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    903903         * @ticket 24674
    904904         */
    905905        public function test_is_tag_with_slug_that_begins_with_a_number_that_clashes_with_another_tag_id() {
    906                 $t1 = self::$factory->tag->create();
     906                $t1 = self::factory()->tag->create();
    907907
    908908                $t2_name = $t1 . '-tag';
    909                 $t2 = self::$factory->tag->create( array(
     909                $t2 = self::factory()->tag->create( array(
    910910                        'slug' => $t2_name,
    911911                ) );
    912912
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    924924         * @ticket 24674
    925925         */
    926926        public function test_is_page_with_page_id_zero_and_random_page_slug() {
    927                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     927                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    928928                $this->go_to( "/?page_id=$post_id" );
    929929
    930930                // override post ID to 0 temporarily for testing
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    946946         * @ticket 24674
    947947         */
    948948        public function test_is_page_with_page_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
    949                 $p1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
     949                $p1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
    950950
    951951                $p2_name = $p1 . '-page';
    952                 $p2 = self::$factory->post->create( array(
     952                $p2 = self::factory()->post->create( array(
    953953                        'post_type' => 'page',
    954954                        'post_name' => $p2_name,
    955955                ) );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    965965        }
    966966
    967967        function test_is_page_template() {
    968                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     968                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    969969                update_post_meta($post_id, '_wp_page_template', 'example.php');
    970970                $this->go_to( "/?page_id=$post_id" );
    971971                $this->assertTrue( is_page_template( 'example.php' ) );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    975975         * @ticket 31271
    976976         */
    977977        function test_is_page_template_default() {
    978                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     978                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    979979                $this->go_to( "/?page_id=$post_id" );
    980980                $this->assertTrue( is_page_template( 'default' ) );
    981981                $this->assertTrue( is_page_template( array( 'random', 'default' ) ) );
    class Tests_Query_Conditionals extends WP_UnitTestCase { 
    985985         * @ticket 31271
    986986         */
    987987        function test_is_page_template_array() {
    988                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     988                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    989989                update_post_meta($post_id, '_wp_page_template', 'example.php');
    990990                $this->go_to( "/?page_id=$post_id" );
    991991                $this->assertFalse( is_page_template( array( 'test.php' ) ) );
  • tests/phpunit/tests/query/dateQuery.php

    diff --git tests/phpunit/tests/query/dateQuery.php tests/phpunit/tests/query/dateQuery.php
    index 0e79426..f40302d 100644
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    3333        }
    3434
    3535        public function test_date_query_before_array() {
    36                 $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
    37                 $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
    38                 $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
    39                 $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
     36                $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
     37                $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
     38                $p3 = self::factory()->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
     39                $p4 = self::factory()->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
    4040
    4141                $posts = $this->_get_query_result( array(
    4242                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    5757         * their minimum values when being used with "before".
    5858         */
    5959        public function test_date_query_before_array_test_defaulting() {
    60                 $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
    61                 $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
     60                $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
     61                $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
    6262
    6363                $posts = $this->_get_query_result( array(
    6464                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    7474        }
    7575
    7676        public function test_date_query_before_string() {
    77                 $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
    78                 $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
    79                 $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
    80                 $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
     77                $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
     78                $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
     79                $p3 = self::factory()->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
     80                $p4 = self::factory()->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
    8181
    8282                $posts = $this->_get_query_result( array(
    8383                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    9191        }
    9292
    9393        public function test_date_query_after_array() {
    94                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) );
    95                 $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
    96                 $p3 = self::$factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) );
     94                $p1 = self::factory()->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) );
     95                $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
     96                $p3 = self::factory()->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) );
    9797
    9898                $posts = $this->_get_query_result( array(
    9999                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    115115         * their maximum values when being used with "after".
    116116         */
    117117        public function test_date_query_after_array_test_defaulting() {
    118                 $p1 = self::$factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) );
    119                 $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
     118                $p1 = self::factory()->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) );
     119                $p2 = self::factory()->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
    120120
    121121                $posts = $this->_get_query_result( array(
    122122                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    132132        }
    133133
    134134        public function test_date_query_after_string() {
    135                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
    136                 $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
    137                 $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
     135                $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
     136                $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
     137                $p3 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
    138138
    139139                $posts = $this->_get_query_result( array(
    140140                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    148148        }
    149149
    150150        public function test_date_query_after_string_inclusive() {
    151                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
    152                 $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
    153                 $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
     151                $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
     152                $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
     153                $p3 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
    154154
    155155                $posts = $this->_get_query_result( array(
    156156                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    168168         * @ticket 26653
    169169         */
    170170        public function test_date_query_inclusive_between_dates() {
    171                 $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) );
    172                 $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
    173                 $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) );
    174                 $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) );
    175                 $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
     171                $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) );
     172                $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
     173                $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) );
     174                $p4 = self::factory()->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) );
     175                $p5 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
    176176
    177177                $posts = $this->_get_query_result( array(
    178178                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    195195         * @ticket 29908
    196196         */
    197197        public function test_beforeafter_with_date_string_Y() {
    198                 $p1 = self::$factory->post->create( array(
     198                $p1 = self::factory()->post->create( array(
    199199                        'post_date' => '2008-05-06 13:00:00',
    200200                ) );
    201                 $p2 = self::$factory->post->create( array(
     201                $p2 = self::factory()->post->create( array(
    202202                        'post_date' => '2007-05-07 13:00:00',
    203203                ) );
    204204
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    228228         * @ticket 29908
    229229         */
    230230        public function test_beforeafter_with_date_string_Y_inclusive() {
    231                 $p1 = self::$factory->post->create( array(
     231                $p1 = self::factory()->post->create( array(
    232232                        'post_date' => '2008-05-06 13:00:00',
    233233                ) );
    234                 $p2 = self::$factory->post->create( array(
     234                $p2 = self::factory()->post->create( array(
    235235                        'post_date' => '2007-05-07 13:00:00',
    236236                ) );
    237237
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    263263         * @ticket 29908
    264264         */
    265265        public function test_beforeafter_with_date_string_Ym() {
    266                 $p1 = self::$factory->post->create( array(
     266                $p1 = self::factory()->post->create( array(
    267267                        'post_date' => '2008-05-06 13:00:00',
    268268                ) );
    269                 $p2 = self::$factory->post->create( array(
     269                $p2 = self::factory()->post->create( array(
    270270                        'post_date' => '2008-04-07 13:00:00',
    271271                ) );
    272272
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    296296         * @ticket 29908
    297297         */
    298298        public function test_beforeafter_with_date_string_Ym_inclusive() {
    299                 $p1 = self::$factory->post->create( array(
     299                $p1 = self::factory()->post->create( array(
    300300                        'post_date' => '2008-05-06 13:00:00',
    301301                ) );
    302                 $p2 = self::$factory->post->create( array(
     302                $p2 = self::factory()->post->create( array(
    303303                        'post_date' => '2008-04-07 13:00:00',
    304304                ) );
    305305
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    331331         * @ticket 29908
    332332         */
    333333        public function test_beforeafter_with_date_string_Ymd() {
    334                 $p1 = self::$factory->post->create( array(
     334                $p1 = self::factory()->post->create( array(
    335335                        'post_date' => '2008-05-06 13:00:00',
    336336                ) );
    337                 $p2 = self::$factory->post->create( array(
     337                $p2 = self::factory()->post->create( array(
    338338                        'post_date' => '2008-05-05 13:00:00',
    339339                ) );
    340340
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    364364         * @ticket 29908
    365365         */
    366366        public function test_beforeafter_with_date_string_Ymd_inclusive() {
    367                 $p1 = self::$factory->post->create( array(
     367                $p1 = self::factory()->post->create( array(
    368368                        'post_date' => '2008-05-06 13:00:00',
    369369                ) );
    370                 $p2 = self::$factory->post->create( array(
     370                $p2 = self::factory()->post->create( array(
    371371                        'post_date' => '2008-05-05 13:00:00',
    372372                ) );
    373373
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    399399         * @ticket 29908
    400400         */
    401401        public function test_beforeafter_with_date_string_YmdHi() {
    402                 $p1 = self::$factory->post->create( array(
     402                $p1 = self::factory()->post->create( array(
    403403                        'post_date' => '2008-05-06 14:05:00',
    404404                ) );
    405                 $p2 = self::$factory->post->create( array(
     405                $p2 = self::factory()->post->create( array(
    406406                        'post_date' => '2008-05-06 14:04:00',
    407407                ) );
    408408
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    432432         * @ticket 29908
    433433         */
    434434        public function test_beforeafter_with_date_string_YmdHi_inclusive() {
    435                 $p1 = self::$factory->post->create( array(
     435                $p1 = self::factory()->post->create( array(
    436436                        'post_date' => '2008-05-06 14:05:00',
    437437                ) );
    438                 $p2 = self::$factory->post->create( array(
     438                $p2 = self::factory()->post->create( array(
    439439                        'post_date' => '2008-05-06 14:04:00',
    440440                ) );
    441441
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    467467         * @ticket 29908
    468468         */
    469469        public function test_beforeafter_with_date_string_YmdHis() {
    470                 $p1 = self::$factory->post->create( array(
     470                $p1 = self::factory()->post->create( array(
    471471                        'post_date' => '2008-05-06 14:05:15',
    472472                ) );
    473                 $p2 = self::$factory->post->create( array(
     473                $p2 = self::factory()->post->create( array(
    474474                        'post_date' => '2008-05-06 14:05:14',
    475475                ) );
    476476
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    500500         * @ticket 29908
    501501         */
    502502        public function test_beforeafter_with_date_string_YmdHis_inclusive() {
    503                 $p1 = self::$factory->post->create( array(
     503                $p1 = self::factory()->post->create( array(
    504504                        'post_date' => '2008-05-06 14:04:15',
    505505                ) );
    506                 $p2 = self::$factory->post->create( array(
     506                $p2 = self::factory()->post->create( array(
    507507                        'post_date' => '2008-05-06 14:04:14',
    508508                ) );
    509509
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    535535         * @ticket 29908
    536536         */
    537537        public function test_beforeafter_with_date_string_non_parseable() {
    538                 $p1 = self::$factory->post->create( array(
     538                $p1 = self::factory()->post->create( array(
    539539                        'post_date' => '2008-05-06 14:05:15',
    540540                ) );
    541                 $p2 = self::$factory->post->create( array(
     541                $p2 = self::factory()->post->create( array(
    542542                        'post_date' => '2008-05-06 14:05:14',
    543543                ) );
    544544
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    564564        }
    565565
    566566        public function test_date_query_year() {
    567                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
    568                 $p2 = self::$factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) );
     567                $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
     568                $p2 = self::factory()->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) );
    569569                $posts = $this->_get_query_result( array(
    570570                        'date_query' => array(
    571571                                array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    578578        }
    579579
    580580        public function test_date_query_month() {
    581                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
    582                 $p2 = self::$factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) );
     581                $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
     582                $p2 = self::factory()->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) );
    583583                $posts = $this->_get_query_result( array(
    584584                        'date_query' => array(
    585585                                array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    592592        }
    593593
    594594        public function test_date_query_week() {
    595                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) );
    596                 $p2 = self::$factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) );
     595                $p1 = self::factory()->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) );
     596                $p2 = self::factory()->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) );
    597597                $posts = $this->_get_query_result( array(
    598598                        'date_query' => array(
    599599                                array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    606606        }
    607607
    608608        public function test_date_query_day() {
    609                 $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) );
    610                 $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
     609                $p1 = self::factory()->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) );
     610                $p2 = self::factory()->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
    611611
    612612                $posts = $this->_get_query_result( array(
    613613                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    621621        }
    622622
    623623        public function test_date_query_dayofweek() {
    624                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
    625                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) );
     624                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
     625                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) );
    626626
    627627                $posts = $this->_get_query_result( array(
    628628                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    639639         * @ticket 28063
    640640         */
    641641        public function test_date_query_dayofweek_iso() {
    642                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) );
    643                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) );
     642                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) );
     643                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) );
    644644
    645645                $posts = $this->_get_query_result( array(
    646646                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    654654        }
    655655
    656656        public function test_date_query_hour() {
    657                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) );
    658                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) );
     657                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) );
     658                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) );
    659659
    660660                $posts = $this->_get_query_result( array(
    661661                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    673673         */
    674674        public function test_date_query_hour_should_not_ignore_0() {
    675675                return;
    676                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) );
    677                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) );
     676                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) );
     677                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) );
    678678
    679679                $posts = $this->_get_query_result( array(
    680680                        'year' => 2014,
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    688688        }
    689689
    690690        public function test_date_query_minute() {
    691                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) );
    692                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
     691                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) );
     692                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
    693693
    694694                $posts = $this->_get_query_result( array(
    695695                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    703703        }
    704704
    705705        public function test_date_query_second() {
    706                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) );
    707                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
     706                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) );
     707                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
    708708
    709709                $posts = $this->_get_query_result( array(
    710710                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    718718        }
    719719
    720720        public function test_date_query_between_two_times() {
    721                 $p1 = self::$factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) );
    722                 $p2 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) );
    723                 $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) );
    724                 $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) );
    725                 $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) );
     721                $p1 = self::factory()->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) );
     722                $p2 = self::factory()->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) );
     723                $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) );
     724                $p4 = self::factory()->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) );
     725                $p5 = self::factory()->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) );
    726726
    727727                $posts = $this->_get_query_result( array(
    728728                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    743743        }
    744744
    745745        public function test_date_query_relation_or() {
    746                 $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) );
    747                 $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
    748                 $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) );
     746                $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) );
     747                $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
     748                $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) );
    749749
    750750                $posts = $this->_get_query_result( array(
    751751                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    763763        }
    764764
    765765        public function test_date_query_compare_greater_than_or_equal_to() {
    766                 $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) );
    767                 $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
    768                 $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) );
    769                 $p4 = self::$factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) );
     766                $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) );
     767                $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
     768                $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) );
     769                $p4 = self::factory()->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) );
    770770
    771771                $posts = $this->_get_query_result( array(
    772772                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    784784        public function test_date_params_monthnum_m_duplicate() {
    785785                global $wpdb;
    786786
    787                 $p1 = self::$factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) );
    788                 $p2 = self::$factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) );
    789                 $p3 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
     787                $p1 = self::factory()->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) );
     788                $p2 = self::factory()->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) );
     789                $p3 = self::factory()->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
    790790
    791791                $posts = $this->_get_query_result( array(
    792792                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    804804        public function test_date_params_week_w_duplicate() {
    805805                global $wpdb;
    806806
    807                 $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) );
    808                 $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) );
    809                 $p3 = self::$factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) );
     807                $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) );
     808                $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) );
     809                $p3 = self::factory()->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) );
    810810
    811811                $posts = $this->_get_query_result( array(
    812812                        'date_query' => array(
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    825825         * @ticket 25775
    826826         */
    827827        public function test_date_query_with_taxonomy_join() {
    828                 $p1 = self::$factory->post->create( array(
     828                $p1 = self::factory()->post->create( array(
    829829                        'post_date' => '2013-04-27 01:01:01',
    830830                ) );
    831                 $p2 = self::$factory->post->create( array(
     831                $p2 = self::factory()->post->create( array(
    832832                        'post_date' => '2013-03-21 01:01:01',
    833833                ) );
    834834
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    857857         * @ticket 29822
    858858         */
    859859        public function test_date_query_one_nested_query() {
    860                 $p1 = self::$factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) );
    861                 $p2 = self::$factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) );
    862                 $p3 = self::$factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) );
    863                 $p4 = self::$factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) );
     860                $p1 = self::factory()->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) );
     861                $p2 = self::factory()->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) );
     862                $p3 = self::factory()->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) );
     863                $p4 = self::factory()->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) );
    864864                $posts = $this->_get_query_result( array(
    865865                        'date_query' => array(
    866866                                'relation' => 'OR',
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    886886         * @ticket 29822
    887887         */
    888888        public function test_date_query_one_nested_query_multiple_columns_relation_and() {
    889                 $p1 = self::$factory->post->create( array(
     889                $p1 = self::factory()->post->create( array(
    890890                        'post_date' => '2012-03-05 15:30:55',
    891891                ) );
    892892                $this->update_post_modified( $p1, '2014-11-03 14:43:00' );
    893893
    894                 $p2 = self::$factory->post->create( array(
     894                $p2 = self::factory()->post->create( array(
    895895                        'post_date' => '2012-05-05 15:30:55',
    896896                ) );
    897897                $this->update_post_modified( $p2, '2014-10-03 14:43:00' );
    898898
    899                 $p3 = self::$factory->post->create( array(
     899                $p3 = self::factory()->post->create( array(
    900900                        'post_date' => '2013-05-05 15:30:55',
    901901                ) );
    902902                $this->update_post_modified( $p3, '2014-10-03 14:43:00' );
    903903
    904                 $p4 = self::$factory->post->create( array(
     904                $p4 = self::factory()->post->create( array(
    905905                        'post_date' => '2012-02-05 15:30:55',
    906906                ) );
    907907                $this->update_post_modified( $p4, '2012-12-03 14:43:00' );
    class Tests_Query_DateQuery extends WP_UnitTestCase { 
    937937         * @ticket 29822
    938938         */
    939939        public function test_date_query_nested_query_multiple_columns_mixed_relations() {
    940                 $p1 = self::$factory->post->create( array(
     940                $p1 = self::factory()->post->create( array(
    941941                        'post_date' => '2012-03-05 15:30:55',
    942942                ) );
    943943                $this->update_post_modified( $p1, '2014-11-03 14:43:00' );
    944944
    945                 $p2 = self::$factory->post->create( array(
     945                $p2 = self::factory()->post->create( array(
    946946                        'post_date' => '2012-05-05 15:30:55',
    947947                ) );
    948948                $this->update_post_modified( $p2, '2014-10-03 14:43:00' );
    949949
    950                 $p3 = self::$factory->post->create( array(
     950                $p3 = self::factory()->post->create( array(
    951951                        'post_date' => '2013-05-05 15:30:55',
    952952                ) );
    953953                $this->update_post_modified( $p3, '2014-10-03 14:43:00' );
    954954
    955                 $p4 = self::$factory->post->create( array(
     955                $p4 = self::factory()->post->create( array(
    956956                        'post_date' => '2012-02-05 15:30:55',
    957957                ) );
    958958                $this->update_post_modified( $p4, '2012-12-03 14:43:00' );
    959959
    960                 $p5 = self::$factory->post->create( array(
     960                $p5 = self::factory()->post->create( array(
    961961                        'post_date' => '2014-02-05 15:30:55',
    962962                ) );
    963963                $this->update_post_modified( $p5, '2013-12-03 14:43:00' );
  • tests/phpunit/tests/query/isTerm.php

    diff --git tests/phpunit/tests/query/isTerm.php tests/phpunit/tests/query/isTerm.php
    index 6dcf4c9..c9a4160 100644
    class Tests_Query_IsTerm extends WP_UnitTestCase { 
    3737
    3838                flush_rewrite_rules();
    3939
    40                 $this->tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) );
    41                 $this->cat_id = self::$factory->category->create( array( 'slug' => 'cat-slug' ) );
    42                 $this->tax_id = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
    43                 $this->tax_id2 = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
    44                 $this->post_id = self::$factory->post->create();
     40                $this->tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) );
     41                $this->cat_id = self::factory()->category->create( array( 'slug' => 'cat-slug' ) );
     42                $this->tax_id = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
     43                $this->tax_id2 = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
     44                $this->post_id = self::factory()->post->create();
    4545                wp_set_object_terms( $this->post_id, $this->cat_id, 'category' );
    4646                wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' );
    4747
    class Tests_Query_IsTerm extends WP_UnitTestCase { 
    245245                remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
    246246
    247247                register_taxonomy( 'testtax2', 'post' );
    248                 $testtax2_term_id = self::$factory->term->create( array(
     248                $testtax2_term_id = self::factory()->term->create( array(
    249249                        'taxonomy' => 'testtax2',
    250250                        'slug' => 'testtax2-slug',
    251251                ) );
  • tests/phpunit/tests/query/metaQuery.php

    diff --git tests/phpunit/tests/query/metaQuery.php tests/phpunit/tests/query/metaQuery.php
    index 1bc5aab..2a9717a 100644
     
    66 */
    77class Tests_Query_MetaQuery extends WP_UnitTestCase {
    88        public function test_meta_query_no_key() {
    9                 $p1 = self::$factory->post->create();
    10                 $p2 = self::$factory->post->create();
    11                 $p3 = self::$factory->post->create();
     9                $p1 = self::factory()->post->create();
     10                $p2 = self::factory()->post->create();
     11                $p3 = self::factory()->post->create();
    1212
    1313                add_post_meta( $p1, 'foo', 'bar' );
    1414                add_post_meta( $p2, 'oof', 'bar' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    3030        }
    3131
    3232        public function test_meta_query_no_value() {
    33                 $p1 = self::$factory->post->create();
    34                 $p2 = self::$factory->post->create();
    35                 $p3 = self::$factory->post->create();
     33                $p1 = self::factory()->post->create();
     34                $p2 = self::factory()->post->create();
     35                $p3 = self::factory()->post->create();
    3636
    3737                add_post_meta( $p1, 'foo', 'bar' );
    3838                add_post_meta( $p2, 'oof', 'bar' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    5454        }
    5555
    5656        public function test_meta_query_single_query_compare_default() {
    57                 $p1 = self::$factory->post->create();
    58                 $p2 = self::$factory->post->create();
     57                $p1 = self::factory()->post->create();
     58                $p2 = self::factory()->post->create();
    5959
    6060                add_post_meta( $p1, 'foo', 'bar' );
    6161
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    7676        }
    7777
    7878        public function test_meta_query_single_query_compare_equals() {
    79                 $p1 = self::$factory->post->create();
    80                 $p2 = self::$factory->post->create();
     79                $p1 = self::factory()->post->create();
     80                $p2 = self::factory()->post->create();
    8181
    8282                add_post_meta( $p1, 'foo', 'bar' );
    8383
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    9999        }
    100100
    101101        public function test_meta_query_single_query_compare_not_equals() {
    102                 $p1 = self::$factory->post->create();
    103                 $p2 = self::$factory->post->create();
    104                 $p3 = self::$factory->post->create();
     102                $p1 = self::factory()->post->create();
     103                $p2 = self::factory()->post->create();
     104                $p3 = self::factory()->post->create();
    105105
    106106                add_post_meta( $p1, 'foo', 'bar' );
    107107                add_post_meta( $p2, 'foo', 'baz' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    124124        }
    125125
    126126        public function test_meta_query_single_query_compare_arithmetic_comparisons() {
    127                 $p1 = self::$factory->post->create();
    128                 $p2 = self::$factory->post->create();
    129                 $p3 = self::$factory->post->create();
     127                $p1 = self::factory()->post->create();
     128                $p2 = self::factory()->post->create();
     129                $p3 = self::factory()->post->create();
    130130
    131131                add_post_meta( $p1, 'foo', '1' );
    132132                add_post_meta( $p2, 'foo', '2' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    202202        }
    203203
    204204        public function test_meta_query_single_query_compare_like() {
    205                 $p1 = self::$factory->post->create();
    206                 $p2 = self::$factory->post->create();
     205                $p1 = self::factory()->post->create();
     206                $p2 = self::factory()->post->create();
    207207
    208208                add_post_meta( $p1, 'foo', 'bar' );
    209209
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    225225        }
    226226
    227227        public function test_meta_query_single_query_compare_not_like() {
    228                 $p1 = self::$factory->post->create();
    229                 $p2 = self::$factory->post->create();
    230                 $p3 = self::$factory->post->create();
     228                $p1 = self::factory()->post->create();
     229                $p2 = self::factory()->post->create();
     230                $p3 = self::factory()->post->create();
    231231
    232232                add_post_meta( $p1, 'foo', 'bar' );
    233233                add_post_meta( $p2, 'foo', 'rab' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    250250        }
    251251
    252252        public function test_meta_query_single_query_compare_between_not_between() {
    253                 $p1 = self::$factory->post->create();
    254                 $p2 = self::$factory->post->create();
    255                 $p3 = self::$factory->post->create();
     253                $p1 = self::factory()->post->create();
     254                $p2 = self::factory()->post->create();
     255                $p3 = self::factory()->post->create();
    256256
    257257                add_post_meta( $p1, 'foo', '1' );
    258258                add_post_meta( $p2, 'foo', '10' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    294294        }
    295295
    296296        public function test_meta_query_single_query_compare_regexp_rlike() {
    297                 $p1 = self::$factory->post->create();
    298                 $p2 = self::$factory->post->create();
     297                $p1 = self::factory()->post->create();
     298                $p2 = self::factory()->post->create();
    299299
    300300                add_post_meta( $p1, 'foo', 'bar' );
    301301                add_post_meta( $p2, 'foo', 'baz' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    335335        }
    336336
    337337        public function test_meta_query_single_query_compare_not_regexp() {
    338                 $p1 = self::$factory->post->create();
    339                 $p2 = self::$factory->post->create();
     338                $p1 = self::factory()->post->create();
     339                $p2 = self::factory()->post->create();
    340340
    341341                add_post_meta( $p1, 'foo', 'bar' );
    342342                add_post_meta( $p2, 'foo', 'baz' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    359359        }
    360360
    361361        public function test_meta_query_relation_default() {
    362                 $p1 = self::$factory->post->create();
    363                 $p2 = self::$factory->post->create();
    364                 $p3 = self::$factory->post->create();
     362                $p1 = self::factory()->post->create();
     363                $p2 = self::factory()->post->create();
     364                $p3 = self::factory()->post->create();
    365365
    366366                add_post_meta( $p1, 'foo', 'foo value 1' );
    367367                add_post_meta( $p1, 'bar', 'bar value 1' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    389389        }
    390390
    391391        public function test_meta_query_relation_or() {
    392                 $post_id = self::$factory->post->create();
     392                $post_id = self::factory()->post->create();
    393393                add_post_meta( $post_id, 'foo', rand_str() );
    394394                add_post_meta( $post_id, 'foo', rand_str() );
    395                 $post_id2 = self::$factory->post->create();
     395                $post_id2 = self::factory()->post->create();
    396396                add_post_meta( $post_id2, 'bar', 'val2' );
    397                 $post_id3 = self::$factory->post->create();
     397                $post_id3 = self::factory()->post->create();
    398398                add_post_meta( $post_id3, 'baz', rand_str() );
    399                 $post_id4 = self::$factory->post->create();
     399                $post_id4 = self::factory()->post->create();
    400400                add_post_meta( $post_id4, 'froo', rand_str() );
    401                 $post_id5 = self::$factory->post->create();
     401                $post_id5 = self::factory()->post->create();
    402402                add_post_meta( $post_id5, 'tango', 'val2' );
    403                 $post_id6 = self::$factory->post->create();
     403                $post_id6 = self::factory()->post->create();
    404404                add_post_meta( $post_id6, 'bar', 'val1' );
    405405
    406406                $query = new WP_Query( array(
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    430430        }
    431431
    432432        public function test_meta_query_relation_and() {
    433                 $post_id = self::$factory->post->create();
     433                $post_id = self::factory()->post->create();
    434434                add_post_meta( $post_id, 'foo', rand_str() );
    435435                add_post_meta( $post_id, 'foo', rand_str() );
    436                 $post_id2 = self::$factory->post->create();
     436                $post_id2 = self::factory()->post->create();
    437437                add_post_meta( $post_id2, 'bar', 'val2' );
    438438                add_post_meta( $post_id2, 'foo', rand_str() );
    439                 $post_id3 = self::$factory->post->create();
     439                $post_id3 = self::factory()->post->create();
    440440                add_post_meta( $post_id3, 'baz', rand_str() );
    441                 $post_id4 = self::$factory->post->create();
     441                $post_id4 = self::factory()->post->create();
    442442                add_post_meta( $post_id4, 'froo', rand_str() );
    443                 $post_id5 = self::$factory->post->create();
     443                $post_id5 = self::factory()->post->create();
    444444                add_post_meta( $post_id5, 'tango', 'val2' );
    445                 $post_id6 = self::$factory->post->create();
     445                $post_id6 = self::factory()->post->create();
    446446                add_post_meta( $post_id6, 'bar', 'val1' );
    447447                add_post_meta( $post_id6, 'foo', rand_str() );
    448                 $post_id7 = self::$factory->post->create();
     448                $post_id7 = self::factory()->post->create();
    449449                add_post_meta( $post_id7, 'foo', rand_str() );
    450450                add_post_meta( $post_id7, 'froo', rand_str() );
    451451                add_post_meta( $post_id7, 'baz', rand_str() );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    499499         * @ticket 30681
    500500         */
    501501        public function test_meta_query_compare_exists() {
    502                 $posts = self::$factory->post->create_many( 3 );
     502                $posts = self::factory()->post->create_many( 3 );
    503503                add_post_meta( $posts[0], 'foo', 'bar' );
    504504                add_post_meta( $posts[2], 'foo', 'baz' );
    505505
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    520520         * @ticket 30681
    521521         */
    522522        public function test_meta_query_compare_exists_with_value_should_convert_to_equals() {
    523                 $posts = self::$factory->post->create_many( 3 );
     523                $posts = self::factory()->post->create_many( 3 );
    524524                add_post_meta( $posts[0], 'foo', 'bar' );
    525525                add_post_meta( $posts[2], 'foo', 'baz' );
    526526
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    542542         * @ticket 30681
    543543         */
    544544        public function test_meta_query_compare_not_exists_should_ignore_value() {
    545                 $posts = self::$factory->post->create_many( 3 );
     545                $posts = self::factory()->post->create_many( 3 );
    546546                add_post_meta( $posts[0], 'foo', 'bar' );
    547547                add_post_meta( $posts[2], 'foo', 'baz' );
    548548
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    564564         * @ticket 18158
    565565         */
    566566        public function test_meta_query_compare_not_exists() {
    567                 $post_id = self::$factory->post->create();
     567                $post_id = self::factory()->post->create();
    568568                add_post_meta( $post_id, 'foo', rand_str() );
    569                 $post_id2 = self::$factory->post->create();
     569                $post_id2 = self::factory()->post->create();
    570570                add_post_meta( $post_id2, 'bar', rand_str() );
    571                 $post_id3 = self::$factory->post->create();
     571                $post_id3 = self::factory()->post->create();
    572572                add_post_meta( $post_id3, 'bar', rand_str() );
    573                 $post_id4 = self::$factory->post->create();
     573                $post_id4 = self::factory()->post->create();
    574574                add_post_meta( $post_id4, 'baz', rand_str() );
    575                 $post_id5 = self::$factory->post->create();
     575                $post_id5 = self::factory()->post->create();
    576576                add_post_meta( $post_id5, 'foo', rand_str() );
    577577
    578578                $query = new WP_Query( array(
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    636636         * @ticket 29062
    637637         */
    638638        public function test_meta_query_compare_not_exists_with_another_condition_relation_or() {
    639                 $posts = self::$factory->post->create_many( 4 );
     639                $posts = self::factory()->post->create_many( 4 );
    640640                update_post_meta( $posts[0], 'color', 'orange' );
    641641                update_post_meta( $posts[1], 'color', 'blue' );
    642642                update_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    672672         * @ticket 24093
    673673         */
    674674        public function test_meta_query_relation_or_compare_equals() {
    675                 $posts = self::$factory->post->create_many( 4 );
     675                $posts = self::factory()->post->create_many( 4 );
    676676                add_post_meta( $posts[0], 'color', 'orange' );
    677677                add_post_meta( $posts[1], 'color', 'blue' );
    678678                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    705705         * @ticket 24093
    706706         */
    707707        public function test_meta_query_relation_or_compare_equals_different_keys() {
    708                 $posts = self::$factory->post->create_many( 4 );
     708                $posts = self::factory()->post->create_many( 4 );
    709709                add_post_meta( $posts[0], 'color', 'orange' );
    710710                add_post_meta( $posts[1], 'color', 'blue' );
    711711                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    738738         * @ticket 24093
    739739         */
    740740        public function test_meta_query_relation_or_compare_equals_and_in() {
    741                 $posts = self::$factory->post->create_many( 4 );
     741                $posts = self::factory()->post->create_many( 4 );
    742742                add_post_meta( $posts[0], 'color', 'orange' );
    743743                add_post_meta( $posts[1], 'color', 'blue' );
    744744                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    771771         * @ticket 24093
    772772         */
    773773        public function test_meta_query_relation_or_compare_equals_and_like() {
    774                 $posts = self::$factory->post->create_many( 4 );
     774                $posts = self::factory()->post->create_many( 4 );
    775775                add_post_meta( $posts[0], 'color', 'orange' );
    776776                add_post_meta( $posts[1], 'color', 'blue' );
    777777                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    804804         * @ticket 24093
    805805         */
    806806        public function test_meta_query_relation_or_compare_equals_and_between() {
    807                 $posts = self::$factory->post->create_many( 4 );
     807                $posts = self::factory()->post->create_many( 4 );
    808808                add_post_meta( $posts[0], 'number_of_colors', '2' );
    809809                add_post_meta( $posts[1], 'number_of_colors', '5' );
    810810                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    838838         * @ticket 24093
    839839         */
    840840        public function test_meta_query_relation_and_compare_in_same_keys() {
    841                 $posts = self::$factory->post->create_many( 4 );
     841                $posts = self::factory()->post->create_many( 4 );
    842842                add_post_meta( $posts[0], 'color', 'orange' );
    843843                add_post_meta( $posts[1], 'color', 'blue' );
    844844                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    873873         * @ticket 24093
    874874         */
    875875        public function test_meta_query_relation_and_compare_in_different_keys() {
    876                 $posts = self::$factory->post->create_many( 4 );
     876                $posts = self::factory()->post->create_many( 4 );
    877877                add_post_meta( $posts[0], 'color', 'orange' );
    878878                add_post_meta( $posts[1], 'color', 'blue' );
    879879                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    908908         * @ticket 24093
    909909         */
    910910        public function test_meta_query_relation_and_compare_not_equals() {
    911                 $posts = self::$factory->post->create_many( 4 );
     911                $posts = self::factory()->post->create_many( 4 );
    912912                add_post_meta( $posts[0], 'color', 'orange' );
    913913                add_post_meta( $posts[1], 'color', 'blue' );
    914914                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    942942         * @ticket 24093
    943943         */
    944944        public function test_meta_query_relation_and_compare_not_equals_different_keys() {
    945                 $posts = self::$factory->post->create_many( 4 );
     945                $posts = self::factory()->post->create_many( 4 );
    946946
    947947                // !shallot, but orange.
    948948                add_post_meta( $posts[0], 'color', 'orange' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    983983         * @ticket 24093
    984984         */
    985985        public function test_meta_query_relation_and_compare_not_equals_not_in() {
    986                 $posts = self::$factory->post->create_many( 4 );
     986                $posts = self::factory()->post->create_many( 4 );
    987987                add_post_meta( $posts[0], 'color', 'orange' );
    988988                add_post_meta( $posts[1], 'color', 'blue' );
    989989                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    10171017         * @ticket 24093
    10181018         */
    10191019        public function test_meta_query_relation_and_compare_not_equals_and_not_like() {
    1020                 $posts = self::$factory->post->create_many( 4 );
     1020                $posts = self::factory()->post->create_many( 4 );
    10211021                add_post_meta( $posts[0], 'color', 'orange' );
    10221022                add_post_meta( $posts[1], 'color', 'blue' );
    10231023                add_post_meta( $posts[1], 'vegetable', 'onion' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    10511051         * @ticket 23033
    10521052         */
    10531053        public function test_meta_query_decimal_results() {
    1054                 $post_1 = self::$factory->post->create();
    1055                 $post_2 = self::$factory->post->create();
    1056                 $post_3 = self::$factory->post->create();
    1057                 $post_4 = self::$factory->post->create();
     1054                $post_1 = self::factory()->post->create();
     1055                $post_2 = self::factory()->post->create();
     1056                $post_3 = self::factory()->post->create();
     1057                $post_4 = self::factory()->post->create();
    10581058
    10591059                update_post_meta( $post_1, 'decimal_value', '-0.3' );
    10601060                update_post_meta( $post_2, 'decimal_value', '0.23409844' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    12261226         * @ticket 29604
    12271227         */
    12281228        public function test_meta_query_with_orderby_meta_value_relation_or() {
    1229                 $posts = self::$factory->post->create_many( 4 );
     1229                $posts = self::factory()->post->create_many( 4 );
    12301230                update_post_meta( $posts[0], 'foo', 5 );
    12311231                update_post_meta( $posts[1], 'foo', 6 );
    12321232                update_post_meta( $posts[2], 'foo', 4 );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    12651265         * @ticket 29604
    12661266         */
    12671267        public function test_meta_query_with_orderby_meta_value_relation_and() {
    1268                 $posts = self::$factory->post->create_many( 4 );
     1268                $posts = self::factory()->post->create_many( 4 );
    12691269                update_post_meta( $posts[0], 'foo', 5 );
    12701270                update_post_meta( $posts[1], 'foo', 6 );
    12711271                update_post_meta( $posts[2], 'foo', 4 );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    13081308         * @ticket 29642
    13091309         */
    13101310        public function test_meta_query_nested() {
    1311                 $p1 = self::$factory->post->create();
    1312                 $p2 = self::$factory->post->create();
    1313                 $p3 = self::$factory->post->create();
     1311                $p1 = self::factory()->post->create();
     1312                $p2 = self::factory()->post->create();
     1313                $p3 = self::factory()->post->create();
    13141314
    13151315                add_post_meta( $p1, 'foo', 'bar' );
    13161316                add_post_meta( $p2, 'foo2', 'bar' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    13491349         * @ticket 29642
    13501350         */
    13511351        public function test_meta_query_nested_two_levels_deep() {
    1352                 $p1 = self::$factory->post->create();
    1353                 $p2 = self::$factory->post->create();
    1354                 $p3 = self::$factory->post->create();
     1352                $p1 = self::factory()->post->create();
     1353                $p2 = self::factory()->post->create();
     1354                $p3 = self::factory()->post->create();
    13551355
    13561356                add_post_meta( $p1, 'foo', 'bar' );
    13571357                add_post_meta( $p3, 'foo2', 'bar' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    13941394        }
    13951395
    13961396        public function test_meta_between_not_between() {
    1397                 $post_id = self::$factory->post->create();
     1397                $post_id = self::factory()->post->create();
    13981398                add_post_meta( $post_id, 'time', 500 );
    1399                 $post_id2 = self::$factory->post->create();
     1399                $post_id2 = self::factory()->post->create();
    14001400                add_post_meta( $post_id2, 'time', 1001 );
    1401                 $post_id3 = self::$factory->post->create();
     1401                $post_id3 = self::factory()->post->create();
    14021402                add_post_meta( $post_id3, 'time', 0 );
    1403                 $post_id4 = self::$factory->post->create();
     1403                $post_id4 = self::factory()->post->create();
    14041404                add_post_meta( $post_id4, 'time', 1 );
    1405                 $post_id5 = self::$factory->post->create();
     1405                $post_id5 = self::factory()->post->create();
    14061406                add_post_meta( $post_id5, 'time', 1000 );
    14071407
    14081408                $args = array(
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    14431443         */
    14441444        public function test_meta_default_compare() {
    14451445                // compare should default to IN when meta_value is an array
    1446                 $post_id = self::$factory->post->create();
     1446                $post_id = self::factory()->post->create();
    14471447                add_post_meta( $post_id, 'foo', 'bar' );
    1448                 $post_id2 = self::$factory->post->create();
     1448                $post_id2 = self::factory()->post->create();
    14491449                add_post_meta( $post_id2, 'bar', 'baz' );
    1450                 $post_id3 = self::$factory->post->create();
     1450                $post_id3 = self::factory()->post->create();
    14511451                add_post_meta( $post_id3, 'foo', 'baz' );
    1452                 $post_id4 = self::$factory->post->create();
     1452                $post_id4 = self::factory()->post->create();
    14531453                add_post_meta( $post_id4, 'baz', 'bar' );
    1454                 $post_id5 = self::$factory->post->create();
     1454                $post_id5 = self::factory()->post->create();
    14551455                add_post_meta( $post_id5, 'foo', rand_str() );
    14561456
    14571457                $posts = get_posts( array(
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    14821482         * @ticket 17264
    14831483         */
    14841484        public function test_duplicate_posts_when_no_key() {
    1485                 $post_id = self::$factory->post->create();
     1485                $post_id = self::factory()->post->create();
    14861486                add_post_meta( $post_id, 'city', 'Lorem' );
    14871487                add_post_meta( $post_id, 'address', '123 Lorem St.' );
    1488                 $post_id2 = self::$factory->post->create();
     1488                $post_id2 = self::factory()->post->create();
    14891489                add_post_meta( $post_id2, 'city', 'Lorem' );
    1490                 $post_id3 = self::$factory->post->create();
     1490                $post_id3 = self::factory()->post->create();
    14911491                add_post_meta( $post_id3, 'city', 'Loren' );
    14921492
    14931493                $args = array(
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    15131513         * @ticket 15292
    15141514         */
    15151515        public function test_empty_meta_value() {
    1516                 $post_id = self::$factory->post->create();
     1516                $post_id = self::factory()->post->create();
    15171517                add_post_meta( $post_id, 'foo', '0' );
    15181518                add_post_meta( $post_id, 'bar', 0 );
    1519                 $post_id2 = self::$factory->post->create();
     1519                $post_id2 = self::factory()->post->create();
    15201520                add_post_meta( $post_id2, 'foo', 1 );
    1521                 $post_id3 = self::$factory->post->create();
     1521                $post_id3 = self::factory()->post->create();
    15221522                add_post_meta( $post_id3, 'baz', 0 );
    1523                 $post_id4 = self::$factory->post->create();
     1523                $post_id4 = self::factory()->post->create();
    15241524                add_post_meta( $post_id4, 'baz', 0 );
    1525                 $post_id5 = self::$factory->post->create();
     1525                $post_id5 = self::factory()->post->create();
    15261526                add_post_meta( $post_id5, 'baz', 0 );
    15271527                add_post_meta( $post_id5, 'bar', '0' );
    1528                 $post_id6 = self::$factory->post->create();
     1528                $post_id6 = self::factory()->post->create();
    15291529                add_post_meta( $post_id6, 'baz', 0 );
    15301530
    15311531                $q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    15771577         * @ticket 31045
    15781578         */
    15791579        public function test_orderby_clause_key() {
    1580                 $posts = self::$factory->post->create_many( 3 );
     1580                $posts = self::factory()->post->create_many( 3 );
    15811581                add_post_meta( $posts[0], 'foo', 'aaa' );
    15821582                add_post_meta( $posts[1], 'foo', 'zzz' );
    15831583                add_post_meta( $posts[2], 'foo', 'jjj' );
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    16011601         * @ticket 31045
    16021602         */
    16031603        public function test_orderby_clause_key_as_secondary_sort() {
    1604                 $p1 = self::$factory->post->create( array(
     1604                $p1 = self::factory()->post->create( array(
    16051605                        'post_date' => '2015-01-28 03:00:00',
    16061606                ) );
    1607                 $p2 = self::$factory->post->create( array(
     1607                $p2 = self::factory()->post->create( array(
    16081608                        'post_date' => '2015-01-28 05:00:00',
    16091609                ) );
    1610                 $p3 = self::$factory->post->create( array(
     1610                $p3 = self::factory()->post->create( array(
    16111611                        'post_date' => '2015-01-28 03:00:00',
    16121612                ) );
    16131613
    class Tests_Query_MetaQuery extends WP_UnitTestCase { 
    16361636         * @ticket 31045
    16371637         */
    16381638        public function test_orderby_more_than_one_clause_key() {
    1639                 $posts = self::$factory->post->create_many( 3 );
     1639                $posts = self::factory()->post->create_many( 3 );
    16401640
    16411641                add_post_meta( $posts[0], 'foo', 'jjj' );
    16421642                add_post_meta( $posts[1], 'foo', 'zzz' );
  • tests/phpunit/tests/query/postStatus.php

    diff --git tests/phpunit/tests/query/postStatus.php tests/phpunit/tests/query/postStatus.php
    index 764cc76..6532d52 100644
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    211211        public function test_single_post_with_nonpublic_status_should_not_be_shown_to_logged_out_users() {
    212212                register_post_type( 'foo_pt' );
    213213                register_post_status( 'foo_ps', array( 'public' => false ) );
    214                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps' ) );
     214                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps' ) );
    215215
    216216                $q = new WP_Query( array(
    217217                        'p' => $p,
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    223223        public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() {
    224224                register_post_type( 'foo_pt' );
    225225                register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) );
    226                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
     226                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
    227227
    228228                wp_set_current_user( self::$author_user_id );
    229229
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    237237        public function test_single_post_with_nonpublic_and_protected_status_should_be_shown_for_user_who_can_edit_others_posts() {
    238238                register_post_type( 'foo_pt' );
    239239                register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) );
    240                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
     240                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
    241241
    242242                wp_set_current_user( self::$editor_user_id );
    243243
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    251251        public function test_single_post_with_nonpublic_and_private_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() {
    252252                register_post_type( 'foo_pt' );
    253253                register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) );
    254                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
     254                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
    255255
    256256                wp_set_current_user( self::$author_user_id );
    257257
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    265265        public function test_single_post_with_nonpublic_and_private_status_should_be_shown_for_user_who_can_edit_others_posts() {
    266266                register_post_type( 'foo_pt' );
    267267                register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) );
    268                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
     268                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
    269269
    270270                wp_set_current_user( self::$editor_user_id );
    271271
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    279279        public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_any_user() {
    280280                register_post_type( 'foo_pt' );
    281281                register_post_status( 'foo_ps', array( 'public' => false ) );
    282                 $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
     282                $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
    283283
    284284                wp_set_current_user( self::$editor_user_id );
    285285
    class Tests_Query_PostStatus extends WP_UnitTestCase { 
    294294         * @ticket 29167
    295295         */
    296296        public function test_specific_post_should_be_returned_if_trash_is_one_of_the_requested_post_statuses() {
    297                 $p1 = self::$factory->post->create( array( 'post_status' => 'trash' ) );
    298                 $p2 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
     297                $p1 = self::factory()->post->create( array( 'post_status' => 'trash' ) );
     298                $p2 = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    299299
    300300                $q = new WP_Query( array(
    301301                        'p' => $p1,
  • tests/phpunit/tests/query/results.php

    diff --git tests/phpunit/tests/query/results.php tests/phpunit/tests/query/results.php
    index 9cd81fc..30a3290 100644
    class Tests_Query_Results extends WP_UnitTestCase { 
    456456         * @ticket 16854
    457457         */
    458458        function test_query_author_vars() {
    459                 $author_1 = self::$factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) );
    460                 $post_1 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) );
     459                $author_1 = self::factory()->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) );
     460                $post_1 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) );
    461461
    462                 $author_2 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
    463                 $post_2 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) );
     462                $author_2 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
     463                $post_2 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) );
    464464
    465                 $author_3 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
    466                 $post_3 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) );
     465                $author_3 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
     466                $post_3 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) );
    467467
    468                 $author_4 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
    469                 $post_4 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) );
     468                $author_4 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
     469                $post_4 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) );
    470470
    471471                $posts = $this->q->query( array(
    472472                        'author' => '',
    class Tests_Query_Results extends WP_UnitTestCase { 
    623623         * @ticket 20308
    624624         */
    625625        function test_post_password() {
    626                 $one   = (string) self::$factory->post->create( array( 'post_password' => '' ) );
    627                 $two   = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) );
    628                 $three = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) );
     626                $one   = (string) self::factory()->post->create( array( 'post_password' => '' ) );
     627                $two   = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) );
     628                $three = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) );
    629629
    630630                $args = array( 'post__in' => array( $one, $two, $three ), 'fields' => 'ids' );
    631631
    class Tests_Query_Results extends WP_UnitTestCase { 
    665665        function test_duplicate_slug_in_hierarchical_post_type() {
    666666                register_post_type( 'handbook', array( 'hierarchical' => true ) );
    667667
    668                 $post_1 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) );
    669                 $post_2 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
    670                 $post_3 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) );
     668                $post_1 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) );
     669                $post_2 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
     670                $post_3 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) );
    671671
    672672                $result = $this->q->query( array( 'handbook' => 'getting-started', 'post_type' => 'handbook' ) );
    673673                $this->assertCount( 1, $result );
    class Tests_Query_Results extends WP_UnitTestCase { 
    679679        function test_child_post_in_hierarchical_post_type_with_default_permalinks() {
    680680                register_post_type( 'handbook', array( 'hierarchical' => true ) );
    681681
    682                 $post_1 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
    683                 $post_2 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) );
     682                $post_1 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
     683                $post_2 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) );
    684684
    685685                $this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) );
    686686
    class Tests_Query_Results extends WP_UnitTestCase { 
    690690
    691691        function test_title() {
    692692                $title = 'Tacos are Cool';
    693                 $post_id = self::$factory->post->create( array(
     693                $post_id = self::factory()->post->create( array(
    694694                        'post_title' => $title,
    695695                        'post_type' => 'post',
    696696                        'post_status' => 'publish'
  • tests/phpunit/tests/query/search.php

    diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
    index 37bd21a..caf862c 100644
    class Tests_Query_Search extends WP_UnitTestCase { 
    3131
    3232        function test_search_order_title_relevance() {
    3333                foreach ( range( 1, 7 ) as $i )
    34                         self::$factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) );
    35                 $post_id = self::$factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) );
     34                        self::factory()->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) );
     35                $post_id = self::factory()->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) );
    3636
    3737                $posts = $this->get_search_results( 'About' );
    3838                $this->assertEquals( $post_id, reset( $posts )->ID );
    class Tests_Query_Search extends WP_UnitTestCase { 
    6363         * @ticket 33988
    6464         */
    6565        public function test_s_should_exclude_term_prefixed_with_dash() {
    66                 $p1 = self::$factory->post->create( array(
     66                $p1 = self::factory()->post->create( array(
    6767                        'post_status' => 'publish',
    6868                        'post_content' => 'This post has foo but also bar',
    6969                ) );
    70                 $p2 = self::$factory->post->create( array(
     70                $p2 = self::factory()->post->create( array(
    7171                        'post_status' => 'publish',
    7272                        'post_content' => 'This post has only foo',
    7373                ) );
    class Tests_Query_Search extends WP_UnitTestCase { 
    8484         * @ticket 33988
    8585         */
    8686        public function test_s_should_exclude_first_term_if_prefixed_with_dash() {
    87                 $p1 = self::$factory->post->create( array(
     87                $p1 = self::factory()->post->create( array(
    8888                        'post_status' => 'publish',
    8989                        'post_content' => 'This post has foo but also bar',
    9090                ) );
    91                 $p2 = self::$factory->post->create( array(
     91                $p2 = self::factory()->post->create( array(
    9292                        'post_status' => 'publish',
    9393                        'post_content' => 'This post has only bar',
    9494                ) );
    class Tests_Query_Search extends WP_UnitTestCase { 
    105105         * @ticket 33988
    106106         */
    107107        public function test_s_should_not_exclude_for_dashes_in_the_middle_of_words() {
    108                 $p1 = self::$factory->post->create( array(
     108                $p1 = self::factory()->post->create( array(
    109109                        'post_status' => 'publish',
    110110                        'post_content' => 'This post has foo but also bar',
    111111                ) );
    112                 $p2 = self::$factory->post->create( array(
     112                $p2 = self::factory()->post->create( array(
    113113                        'post_status' => 'publish',
    114114                        'post_content' => 'This post has only bar',
    115115                ) );
    116                 $p3 = self::$factory->post->create( array(
     116                $p3 = self::factory()->post->create( array(
    117117                        'post_status' => 'publish',
    118118                        'post_content' => 'This post has only foo-bar',
    119119                ) );
  • tests/phpunit/tests/query/setupPostdata.php

    diff --git tests/phpunit/tests/query/setupPostdata.php tests/phpunit/tests/query/setupPostdata.php
    index 5381a97..73ec7bd 100644
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    3939        }
    4040
    4141        public function test_id() {
    42                 $p = self::$factory->post->create_and_get();
     42                $p = self::factory()->post->create_and_get();
    4343                setup_postdata( $p );
    4444
    4545                $this->assertNotEmpty( $p->ID );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    5050         * @ticket 30970
    5151         */
    5252        public function test_setup_by_id() {
    53                 $p = self::$factory->post->create_and_get();
     53                $p = self::factory()->post->create_and_get();
    5454                setup_postdata( $p->ID );
    5555
    5656                $this->assertSame( $p->ID, $GLOBALS['id'] );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    7272         * @ticket 30970
    7373         */
    7474        public function test_setup_by_postish_object() {
    75                 $p = self::$factory->post->create();
     75                $p = self::factory()->post->create();
    7676
    7777                $post = new stdClass();
    7878                $post->ID = $p;
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    8282        }
    8383
    8484        public function test_authordata() {
    85                 $u = self::$factory->user->create_and_get();
    86                 $p = self::$factory->post->create_and_get( array(
     85                $u = self::factory()->user->create_and_get();
     86                $p = self::factory()->post->create_and_get( array(
    8787                        'post_author' => $u->ID,
    8888                ) );
    8989                setup_postdata( $p );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    9393        }
    9494
    9595        public function test_currentday() {
    96                 $p = self::$factory->post->create_and_get( array(
     96                $p = self::factory()->post->create_and_get( array(
    9797                        'post_date' => '1980-09-09 06:30:00',
    9898                ) );
    9999                setup_postdata( $p );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    102102        }
    103103
    104104        public function test_currentmonth() {
    105                 $p = self::$factory->post->create_and_get( array(
     105                $p = self::factory()->post->create_and_get( array(
    106106                        'post_date' => '1980-09-09 06:30:00',
    107107                ) );
    108108                setup_postdata( $p );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    111111        }
    112112
    113113        public function test_secondary_query_post_vars() {
    114                 $users = self::$factory->user->create_many( 2 );
     114                $users = self::factory()->user->create_many( 2 );
    115115
    116                 $post1 = self::$factory->post->create_and_get( array(
     116                $post1 = self::factory()->post->create_and_get( array(
    117117                        'post_author' => $users[0],
    118118                        'post_date' => '2012-02-02 02:00:00',
    119119                ) );
    120120
    121                 $post2 = self::$factory->post->create_and_get( array(
     121                $post2 = self::factory()->post->create_and_get( array(
    122122                        'post_author' => $users[1],
    123123                        'post_date' => '2013-03-03 03:00:00',
    124124                ) );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    157157        }
    158158
    159159        public function test_single_page() {
    160                 $post = self::$factory->post->create_and_get( array(
     160                $post = self::factory()->post->create_and_get( array(
    161161                        'post_content' => 'Page 0',
    162162                ) );
    163163                setup_postdata( $post );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    168168        }
    169169
    170170        public function test_multi_page() {
    171                 $post = self::$factory->post->create_and_get( array(
     171                $post = self::factory()->post->create_and_get( array(
    172172                        'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    173173                ) );
    174174                setup_postdata( $post );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    182182         * @ticket 16746
    183183         */
    184184        public function test_nextpage_at_start_of_content() {
    185                 $post = self::$factory->post->create_and_get( array(
     185                $post = self::factory()->post->create_and_get( array(
    186186                        'post_content' => '<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    187187                ) );
    188188                setup_postdata( $post );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    193193        }
    194194
    195195        public function test_trim_nextpage_linebreaks() {
    196                 $post = self::$factory->post->create_and_get( array(
     196                $post = self::factory()->post->create_and_get( array(
    197197                        'post_content' => "Page 0\n<!--nextpage-->\nPage 1\nhas a line break\n<!--nextpage-->Page 2<!--nextpage-->\n\nPage 3",
    198198                ) );
    199199                setup_postdata( $post );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    205205         * @ticket 25349
    206206         */
    207207        public function test_secondary_query_nextpage() {
    208                 $post1 = self::$factory->post->create( array(
     208                $post1 = self::factory()->post->create( array(
    209209                        'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2',
    210210                ) );
    211                 $post2 = self::$factory->post->create( array(
     211                $post2 = self::factory()->post->create( array(
    212212                        'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2',
    213213                ) );
    214214
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    237237        }
    238238
    239239        public function test_page_from_wp_query() {
    240                 $page = self::$factory->post->create_and_get( array(
     240                $page = self::factory()->post->create_and_get( array(
    241241                        'post_type' => 'page',
    242242                ) );
    243243
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    250250        }
    251251
    252252        public function test_page_when_on_page() {
    253                 $page = self::$factory->post->create_and_get( array(
     253                $page = self::factory()->post->create_and_get( array(
    254254                        'post_type' => 'page',
    255255                ) );
    256256                $this->go_to( get_permalink( $page ) );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    263263         * @ticket 20904
    264264         */
    265265        public function test_secondary_query_page() {
    266                 $post = self::$factory->post->create_and_get();
     266                $post = self::factory()->post->create_and_get();
    267267                $this->go_to( '/?page=3' );
    268268                setup_postdata( $post );
    269269
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    271271                $this->assertSame( 3, $GLOBALS['page'] );
    272272
    273273                // Secondary loop.
    274                 $posts = self::$factory->post->create_many( 5 );
     274                $posts = self::factory()->post->create_many( 5 );
    275275                $q = new WP_Query( array(
    276276                        'page' => 4,
    277277                        'posts_per_page' => 1,
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    294294         * @ticket 20904
    295295         */
    296296        public function test_more_when_on_setup_post() {
    297                 $post = self::$factory->post->create_and_get();
     297                $post = self::factory()->post->create_and_get();
    298298                $this->go_to( get_permalink( $post ) );
    299299                setup_postdata( $post );
    300300
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    307307         * $more should not be true when the set-up post is not the same as the current post.
    308308         */
    309309        public function test_more_when_on_single() {
    310                 $post1 = self::$factory->post->create_and_get();
    311                 $post2 = self::$factory->post->create_and_get();
     310                $post1 = self::factory()->post->create_and_get();
     311                $post2 = self::factory()->post->create_and_get();
    312312                $this->go_to( get_permalink( $post1 ) );
    313313                setup_postdata( $post2 );
    314314
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    321321         * $more should not be true when the set-up post is not the same as the current page.
    322322         */
    323323        public function test_more_when_on_page() {
    324                 $post = self::$factory->post->create_and_get();
    325                 $page = self::$factory->post->create_and_get( array(
     324                $post = self::factory()->post->create_and_get();
     325                $page = self::factory()->post->create_and_get( array(
    326326                        'post_type' => 'page',
    327327                ) );
    328328                $this->go_to( get_permalink( $page ) );
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    335335         * @ticket 20904
    336336         */
    337337        public function test_more_when_on_feed() {
    338                 $post = self::$factory->post->create_and_get();
     338                $post = self::factory()->post->create_and_get();
    339339                $this->go_to( '/?feed=rss' );
    340340                setup_postdata( $post );
    341341
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    347347         * @ticket 25349
    348348         */
    349349        public function test_secondary_query_more() {
    350                 $post = self::$factory->post->create_and_get();
     350                $post = self::factory()->post->create_and_get();
    351351                $this->go_to( get_permalink( $post ) );
    352352                setup_postdata( $post );
    353353
    class Tests_Query_SetupPostdata extends WP_UnitTestCase { 
    379379         * global $post should use the content of $a_post rather then the global post.
    380380         */
    381381        function test_setup_postdata_loop() {
    382                 $post_id = self::$factory->post->create( array( 'post_content' => 'global post' ) );
     382                $post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) );
    383383                $GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id );
    384384
    385                 $ids = self::$factory->post->create_many(5);
     385                $ids = self::factory()->post->create_many(5);
    386386                foreach ( $ids as $id ) {
    387387                        $page = get_post( $id );
    388388                        if ( $page ) {
  • tests/phpunit/tests/query/taxQuery.php

    diff --git tests/phpunit/tests/query/taxQuery.php tests/phpunit/tests/query/taxQuery.php
    index cd495b8..8248b19 100644
     
    66 */
    77class Tests_Query_TaxQuery extends WP_UnitTestCase {
    88        public function test_tax_query_single_query_single_term_field_slug() {
    9                 $t = self::$factory->term->create( array(
     9                $t = self::factory()->term->create( array(
    1010                        'taxonomy' => 'category',
    1111                        'slug' => 'foo',
    1212                        'name' => 'Foo',
    1313                ) );
    14                 $p1 = self::$factory->post->create();
    15                 $p2 = self::$factory->post->create();
     14                $p1 = self::factory()->post->create();
     15                $p2 = self::factory()->post->create();
    1616
    1717                wp_set_post_terms( $p1, $t, 'category' );
    1818
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    3333        }
    3434
    3535        public function test_tax_query_single_query_single_term_field_name() {
    36                 $t = self::$factory->term->create( array(
     36                $t = self::factory()->term->create( array(
    3737                        'taxonomy' => 'category',
    3838                        'slug' => 'foo',
    3939                        'name' => 'Foo',
    4040                ) );
    41                 $p1 = self::$factory->post->create();
    42                 $p2 = self::$factory->post->create();
     41                $p1 = self::factory()->post->create();
     42                $p2 = self::factory()->post->create();
    4343
    4444                wp_set_post_terms( $p1, $t, 'category' );
    4545
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    6565        public function test_field_name_should_work_for_names_with_spaces() {
    6666                register_taxonomy( 'wptests_tax', 'post' );
    6767
    68                 $t = self::$factory->term->create( array(
     68                $t = self::factory()->term->create( array(
    6969                        'taxonomy' => 'wptests_tax',
    7070                        'slug' => 'foo',
    7171                        'name' => 'Foo Bar',
    7272                ) );
    73                 $p1 = self::$factory->post->create();
    74                 $p2 = self::$factory->post->create();
     73                $p1 = self::factory()->post->create();
     74                $p2 = self::factory()->post->create();
    7575
    7676                wp_set_object_terms( $p1, $t, 'wptests_tax' );
    7777
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    9090        }
    9191
    9292        public function test_tax_query_single_query_single_term_field_term_taxonomy_id() {
    93                 $t = self::$factory->term->create( array(
     93                $t = self::factory()->term->create( array(
    9494                        'taxonomy' => 'category',
    9595                        'slug' => 'foo',
    9696                        'name' => 'Foo',
    9797                ) );
    98                 $p1 = self::$factory->post->create();
    99                 $p2 = self::$factory->post->create();
     98                $p1 = self::factory()->post->create();
     99                $p2 = self::factory()->post->create();
    100100
    101101                $tt_ids = wp_set_post_terms( $p1, $t, 'category' );
    102102
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    117117        }
    118118
    119119        public function test_tax_query_single_query_single_term_field_term_id() {
    120                 $t = self::$factory->term->create( array(
     120                $t = self::factory()->term->create( array(
    121121                        'taxonomy' => 'category',
    122122                        'slug' => 'foo',
    123123                        'name' => 'Foo',
    124124                ) );
    125                 $p1 = self::$factory->post->create();
    126                 $p2 = self::$factory->post->create();
     125                $p1 = self::factory()->post->create();
     126                $p2 = self::factory()->post->create();
    127127
    128128                wp_set_post_terms( $p1, $t, 'category' );
    129129
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    144144        }
    145145
    146146        public function test_tax_query_single_query_single_term_operator_in() {
    147                 $t = self::$factory->term->create( array(
     147                $t = self::factory()->term->create( array(
    148148                        'taxonomy' => 'category',
    149149                        'slug' => 'foo',
    150150                        'name' => 'Foo',
    151151                ) );
    152                 $p1 = self::$factory->post->create();
    153                 $p2 = self::$factory->post->create();
     152                $p1 = self::factory()->post->create();
     153                $p2 = self::factory()->post->create();
    154154
    155155                wp_set_post_terms( $p1, $t, 'category' );
    156156
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    172172        }
    173173
    174174        public function test_tax_query_single_query_single_term_operator_not_in() {
    175                 $t = self::$factory->term->create( array(
     175                $t = self::factory()->term->create( array(
    176176                        'taxonomy' => 'category',
    177177                        'slug' => 'foo',
    178178                        'name' => 'Foo',
    179179                ) );
    180                 $p1 = self::$factory->post->create();
    181                 $p2 = self::$factory->post->create();
     180                $p1 = self::factory()->post->create();
     181                $p2 = self::factory()->post->create();
    182182
    183183                wp_set_post_terms( $p1, $t, 'category' );
    184184
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    200200        }
    201201
    202202        public function test_tax_query_single_query_single_term_operator_and() {
    203                 $t = self::$factory->term->create( array(
     203                $t = self::factory()->term->create( array(
    204204                        'taxonomy' => 'category',
    205205                        'slug' => 'foo',
    206206                        'name' => 'Foo',
    207207                ) );
    208                 $p1 = self::$factory->post->create();
    209                 $p2 = self::$factory->post->create();
     208                $p1 = self::factory()->post->create();
     209                $p2 = self::factory()->post->create();
    210210
    211211                wp_set_post_terms( $p1, $t, 'category' );
    212212
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    228228        }
    229229
    230230        public function test_tax_query_single_query_multiple_terms_operator_in() {
    231                 $t1 = self::$factory->term->create( array(
     231                $t1 = self::factory()->term->create( array(
    232232                        'taxonomy' => 'category',
    233233                        'slug' => 'foo',
    234234                        'name' => 'Foo',
    235235                ) );
    236                 $t2 = self::$factory->term->create( array(
     236                $t2 = self::factory()->term->create( array(
    237237                        'taxonomy' => 'category',
    238238                        'slug' => 'bar',
    239239                        'name' => 'Bar',
    240240                ) );
    241                 $p1 = self::$factory->post->create();
    242                 $p2 = self::$factory->post->create();
    243                 $p3 = self::$factory->post->create();
     241                $p1 = self::factory()->post->create();
     242                $p2 = self::factory()->post->create();
     243                $p3 = self::factory()->post->create();
    244244
    245245                wp_set_post_terms( $p1, $t1, 'category' );
    246246                wp_set_post_terms( $p2, $t2, 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    263263        }
    264264
    265265        public function test_tax_query_single_query_multiple_terms_operator_not_in() {
    266                 $t1 = self::$factory->term->create( array(
     266                $t1 = self::factory()->term->create( array(
    267267                        'taxonomy' => 'category',
    268268                        'slug' => 'foo',
    269269                        'name' => 'Foo',
    270270                ) );
    271                 $t2 = self::$factory->term->create( array(
     271                $t2 = self::factory()->term->create( array(
    272272                        'taxonomy' => 'category',
    273273                        'slug' => 'bar',
    274274                        'name' => 'Bar',
    275275                ) );
    276                 $p1 = self::$factory->post->create();
    277                 $p2 = self::$factory->post->create();
    278                 $p3 = self::$factory->post->create();
     276                $p1 = self::factory()->post->create();
     277                $p2 = self::factory()->post->create();
     278                $p3 = self::factory()->post->create();
    279279
    280280                wp_set_post_terms( $p1, $t1, 'category' );
    281281                wp_set_post_terms( $p2, $t2, 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    301301         * @ticket 18105
    302302         */
    303303        public function test_tax_query_single_query_multiple_queries_operator_not_in() {
    304                 $t1 = self::$factory->term->create( array(
     304                $t1 = self::factory()->term->create( array(
    305305                        'taxonomy' => 'category',
    306306                        'slug' => 'foo',
    307307                        'name' => 'Foo',
    308308                ) );
    309                 $t2 = self::$factory->term->create( array(
     309                $t2 = self::factory()->term->create( array(
    310310                        'taxonomy' => 'category',
    311311                        'slug' => 'bar',
    312312                        'name' => 'Bar',
    313313                ) );
    314                 $p1 = self::$factory->post->create();
    315                 $p2 = self::$factory->post->create();
    316                 $p3 = self::$factory->post->create();
     314                $p1 = self::factory()->post->create();
     315                $p2 = self::factory()->post->create();
     316                $p3 = self::factory()->post->create();
    317317
    318318                wp_set_post_terms( $p1, $t1, 'category' );
    319319                wp_set_post_terms( $p2, $t2, 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    343343        }
    344344
    345345        public function test_tax_query_single_query_multiple_terms_operator_and() {
    346                 $t1 = self::$factory->term->create( array(
     346                $t1 = self::factory()->term->create( array(
    347347                        'taxonomy' => 'category',
    348348                        'slug' => 'foo',
    349349                        'name' => 'Foo',
    350350                ) );
    351                 $t2 = self::$factory->term->create( array(
     351                $t2 = self::factory()->term->create( array(
    352352                        'taxonomy' => 'category',
    353353                        'slug' => 'bar',
    354354                        'name' => 'Bar',
    355355                ) );
    356                 $p1 = self::$factory->post->create();
    357                 $p2 = self::$factory->post->create();
    358                 $p3 = self::$factory->post->create();
     356                $p1 = self::factory()->post->create();
     357                $p2 = self::factory()->post->create();
     358                $p3 = self::factory()->post->create();
    359359
    360360                wp_set_object_terms( $p1, $t1, 'category' );
    361361                wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    384384                register_taxonomy( 'wptests_tax1', 'post' );
    385385                register_taxonomy( 'wptests_tax2', 'post' );
    386386
    387                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    388                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     387                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     388                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    389389
    390                 $p1 = self::$factory->post->create();
    391                 $p2 = self::$factory->post->create();
    392                 $p3 = self::$factory->post->create();
     390                $p1 = self::factory()->post->create();
     391                $p2 = self::factory()->post->create();
     392                $p3 = self::factory()->post->create();
    393393
    394394                wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
    395395                wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    416416                register_taxonomy( 'wptests_tax1', 'post' );
    417417                register_taxonomy( 'wptests_tax2', 'post' );
    418418
    419                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    420                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     419                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     420                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    421421
    422                 $p1 = self::$factory->post->create();
    423                 $p2 = self::$factory->post->create();
    424                 $p3 = self::$factory->post->create();
     422                $p1 = self::factory()->post->create();
     423                $p2 = self::factory()->post->create();
     424                $p3 = self::factory()->post->create();
    425425
    426426                wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
    427427                wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    448448                register_taxonomy( 'wptests_tax1', 'post' );
    449449                register_taxonomy( 'wptests_tax2', 'post' );
    450450
    451                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    452                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     451                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     452                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    453453
    454                 $p1 = self::$factory->post->create();
    455                 $p2 = self::$factory->post->create();
    456                 $p3 = self::$factory->post->create();
     454                $p1 = self::factory()->post->create();
     455                $p2 = self::factory()->post->create();
     456                $p3 = self::factory()->post->create();
    457457
    458458                wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
    459459                wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    481481                register_taxonomy( 'wptests_tax1', 'post' );
    482482                register_taxonomy( 'wptests_tax2', 'post' );
    483483
    484                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    485                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     484                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     485                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    486486
    487                 $p1 = self::$factory->post->create();
    488                 $p2 = self::$factory->post->create();
    489                 $p3 = self::$factory->post->create();
     487                $p1 = self::factory()->post->create();
     488                $p2 = self::factory()->post->create();
     489                $p3 = self::factory()->post->create();
    490490
    491491                wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
    492492                wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    506506        }
    507507
    508508        public function test_tax_query_multiple_queries_relation_and() {
    509                 $t1 = self::$factory->term->create( array(
     509                $t1 = self::factory()->term->create( array(
    510510                        'taxonomy' => 'category',
    511511                        'slug' => 'foo',
    512512                        'name' => 'Foo',
    513513                ) );
    514                 $t2 = self::$factory->term->create( array(
     514                $t2 = self::factory()->term->create( array(
    515515                        'taxonomy' => 'category',
    516516                        'slug' => 'bar',
    517517                        'name' => 'Bar',
    518518                ) );
    519                 $p1 = self::$factory->post->create();
    520                 $p2 = self::$factory->post->create();
    521                 $p3 = self::$factory->post->create();
     519                $p1 = self::factory()->post->create();
     520                $p2 = self::factory()->post->create();
     521                $p3 = self::factory()->post->create();
    522522
    523523                wp_set_object_terms( $p1, $t1, 'category' );
    524524                wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    546546        }
    547547
    548548        public function test_tax_query_multiple_queries_relation_or() {
    549                 $t1 = self::$factory->term->create( array(
     549                $t1 = self::factory()->term->create( array(
    550550                        'taxonomy' => 'category',
    551551                        'slug' => 'foo',
    552552                        'name' => 'Foo',
    553553                ) );
    554                 $t2 = self::$factory->term->create( array(
     554                $t2 = self::factory()->term->create( array(
    555555                        'taxonomy' => 'category',
    556556                        'slug' => 'bar',
    557557                        'name' => 'Bar',
    558558                ) );
    559                 $p1 = self::$factory->post->create();
    560                 $p2 = self::$factory->post->create();
    561                 $p3 = self::$factory->post->create();
     559                $p1 = self::factory()->post->create();
     560                $p2 = self::factory()->post->create();
     561                $p3 = self::factory()->post->create();
    562562
    563563                wp_set_object_terms( $p1, $t1, 'category' );
    564564                wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    586586        }
    587587
    588588        public function test_tax_query_multiple_queries_different_taxonomies() {
    589                 $t1 = self::$factory->term->create( array(
     589                $t1 = self::factory()->term->create( array(
    590590                        'taxonomy' => 'post_tag',
    591591                        'slug' => 'foo',
    592592                        'name' => 'Foo',
    593593                ) );
    594                 $t2 = self::$factory->term->create( array(
     594                $t2 = self::factory()->term->create( array(
    595595                        'taxonomy' => 'category',
    596596                        'slug' => 'bar',
    597597                        'name' => 'Bar',
    598598                ) );
    599                 $p1 = self::$factory->post->create();
    600                 $p2 = self::$factory->post->create();
    601                 $p3 = self::$factory->post->create();
     599                $p1 = self::factory()->post->create();
     600                $p2 = self::factory()->post->create();
     601                $p3 = self::factory()->post->create();
    602602
    603603                wp_set_object_terms( $p1, $t1, 'post_tag' );
    604604                wp_set_object_terms( $p2, $t2, 'category' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    632632                register_taxonomy( 'foo', 'post' );
    633633                register_taxonomy( 'bar', 'post' );
    634634
    635                 $foo_term_1 = self::$factory->term->create( array(
     635                $foo_term_1 = self::factory()->term->create( array(
    636636                        'taxonomy' => 'foo',
    637637                ) );
    638                 $foo_term_2 = self::$factory->term->create( array(
     638                $foo_term_2 = self::factory()->term->create( array(
    639639                        'taxonomy' => 'foo',
    640640                ) );
    641                 $bar_term_1 = self::$factory->term->create( array(
     641                $bar_term_1 = self::factory()->term->create( array(
    642642                        'taxonomy' => 'bar',
    643643                ) );
    644                 $bar_term_2 = self::$factory->term->create( array(
     644                $bar_term_2 = self::factory()->term->create( array(
    645645                        'taxonomy' => 'bar',
    646646                ) );
    647647
    648                 $p1 = self::$factory->post->create();
    649                 $p2 = self::$factory->post->create();
    650                 $p3 = self::$factory->post->create();
     648                $p1 = self::factory()->post->create();
     649                $p2 = self::factory()->post->create();
     650                $p3 = self::factory()->post->create();
    651651
    652652                wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
    653653                wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    704704                register_taxonomy( 'foo', 'post' );
    705705                register_taxonomy( 'bar', 'post' );
    706706
    707                 $foo_term_1 = self::$factory->term->create( array(
     707                $foo_term_1 = self::factory()->term->create( array(
    708708                        'taxonomy' => 'foo',
    709709                ) );
    710                 $foo_term_2 = self::$factory->term->create( array(
     710                $foo_term_2 = self::factory()->term->create( array(
    711711                        'taxonomy' => 'foo',
    712712                ) );
    713                 $bar_term_1 = self::$factory->term->create( array(
     713                $bar_term_1 = self::factory()->term->create( array(
    714714                        'taxonomy' => 'bar',
    715715                ) );
    716                 $bar_term_2 = self::$factory->term->create( array(
     716                $bar_term_2 = self::factory()->term->create( array(
    717717                        'taxonomy' => 'bar',
    718718                ) );
    719719
    720                 $p1 = self::$factory->post->create();
    721                 $p2 = self::$factory->post->create();
    722                 $p3 = self::$factory->post->create();
     720                $p1 = self::factory()->post->create();
     721                $p2 = self::factory()->post->create();
     722                $p3 = self::factory()->post->create();
    723723
    724724                wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
    725725                wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    768768                register_taxonomy( 'foo', 'post' );
    769769                register_taxonomy( 'bar', 'post' );
    770770
    771                 $foo_term_1 = self::$factory->term->create( array(
     771                $foo_term_1 = self::factory()->term->create( array(
    772772                        'taxonomy' => 'foo',
    773773                ) );
    774                 $foo_term_2 = self::$factory->term->create( array(
     774                $foo_term_2 = self::factory()->term->create( array(
    775775                        'taxonomy' => 'foo',
    776776                ) );
    777                 $bar_term_1 = self::$factory->term->create( array(
     777                $bar_term_1 = self::factory()->term->create( array(
    778778                        'taxonomy' => 'bar',
    779779                ) );
    780                 $bar_term_2 = self::$factory->term->create( array(
     780                $bar_term_2 = self::factory()->term->create( array(
    781781                        'taxonomy' => 'bar',
    782782                ) );
    783783
    784                 $p1 = self::$factory->post->create();
    785                 $p2 = self::$factory->post->create();
    786                 $p3 = self::$factory->post->create();
    787                 $p4 = self::$factory->post->create();
     784                $p1 = self::factory()->post->create();
     785                $p2 = self::factory()->post->create();
     786                $p3 = self::factory()->post->create();
     787                $p4 = self::factory()->post->create();
    788788
    789789                wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
    790790                wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    840840        public function test_tax_query_relation_or_both_clauses_empty_terms() {
    841841                // An empty tax query should return an empty array, not all posts.
    842842
    843                 self::$factory->post->create_many( 2 );
     843                self::factory()->post->create_many( 2 );
    844844
    845845                $query = new WP_Query( array(
    846846                        'fields' => 'ids',
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    873873        public function test_tax_query_relation_or_one_clause_empty_terms() {
    874874                // An empty tax query should return an empty array, not all posts.
    875875
    876                 self::$factory->post->create_many( 2 );
     876                self::factory()->post->create_many( 2 );
    877877
    878878                $query = new WP_Query( array(
    879879                        'fields' => 'ids',
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    901901        }
    902902
    903903        public function test_tax_query_include_children() {
    904                 $cat_a = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
    905                 $cat_b = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
    906                 $cat_c = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
    907                 $cat_d = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
     904                $cat_a = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
     905                $cat_b = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
     906                $cat_c = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
     907                $cat_d = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
    908908
    909                 $post_a = self::$factory->post->create( array( 'post_category' => array( $cat_a ) ) );
    910                 $post_b = self::$factory->post->create( array( 'post_category' => array( $cat_b ) ) );
    911                 $post_c = self::$factory->post->create( array( 'post_category' => array( $cat_c ) ) );
    912                 $post_d = self::$factory->post->create( array( 'post_category' => array( $cat_d ) ) );
     909                $post_a = self::factory()->post->create( array( 'post_category' => array( $cat_a ) ) );
     910                $post_b = self::factory()->post->create( array( 'post_category' => array( $cat_b ) ) );
     911                $post_c = self::factory()->post->create( array( 'post_category' => array( $cat_c ) ) );
     912                $post_d = self::factory()->post->create( array( 'post_category' => array( $cat_d ) ) );
    913913
    914914                $posts = get_posts( array(
    915915                        'fields' => 'ids',
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    10091009                $q = new WP_Query();
    10101010
    10111011                register_taxonomy_for_object_type( 'post_tag', 'attachment:image' );
    1012                 $tag_id = self::$factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
    1013                 $image_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
     1012                $tag_id = self::factory()->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
     1013                $image_id = self::factory()->attachment->create_object( 'image.jpg', 0, array(
    10141014                        'post_mime_type' => 'image/jpeg',
    10151015                        'post_type' => 'attachment'
    10161016                ) );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    10351035        }
    10361036
    10371037        public function test_tax_query_no_taxonomy() {
    1038                 $cat_id = self::$factory->category->create( array( 'name' => 'alpha' ) );
    1039                 self::$factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
     1038                $cat_id = self::factory()->category->create( array( 'name' => 'alpha' ) );
     1039                self::factory()->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
    10401040
    10411041                $response1 = new WP_Query( array(
    10421042                        'tax_query' => array(
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    10761076        public function test_term_taxonomy_id_field_no_taxonomy() {
    10771077                $q = new WP_Query();
    10781078
    1079                 $posts = self::$factory->post->create_many( 5 );
     1079                $posts = self::factory()->post->create_many( 5 );
    10801080
    10811081                $cats = $tags = array();
    10821082
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    11551155         */
    11561156        public function test_populate_taxonomy_query_var_from_tax_query() {
    11571157                register_taxonomy( 'foo', 'post' );
    1158                 $t = self::$factory->term->create( array(
     1158                $t = self::factory()->term->create( array(
    11591159                        'taxonomy' => 'foo',
    11601160                ) );
    1161                 $c = self::$factory->term->create( array(
     1161                $c = self::factory()->term->create( array(
    11621162                        'taxonomy' => 'category',
    11631163                ) );
    11641164
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    11911191        public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() {
    11921192                register_taxonomy( 'foo', 'post' );
    11931193                register_taxonomy( 'foo1', 'post' );
    1194                 $t = self::$factory->term->create( array(
     1194                $t = self::factory()->term->create( array(
    11951195                        'taxonomy' => 'foo',
    11961196                ) );
    11971197
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    12131213
    12141214        public function test_populate_term_query_var_from_tax_query() {
    12151215                register_taxonomy( 'foo', 'post' );
    1216                 $t = self::$factory->term->create( array(
     1216                $t = self::factory()->term->create( array(
    12171217                        'taxonomy' => 'foo',
    12181218                        'slug' => 'bar',
    12191219                ) );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    12351235
    12361236        public function test_populate_term_id_query_var_from_tax_query() {
    12371237                register_taxonomy( 'foo', 'post' );
    1238                 $t = self::$factory->term->create( array(
     1238                $t = self::factory()->term->create( array(
    12391239                        'taxonomy' => 'foo',
    12401240                        'slug' => 'bar',
    12411241                ) );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    12601260         */
    12611261        public function test_populate_cat_category_name_query_var_from_tax_query() {
    12621262                register_taxonomy( 'foo', 'post' );
    1263                 $t = self::$factory->term->create( array(
     1263                $t = self::factory()->term->create( array(
    12641264                        'taxonomy' => 'foo',
    12651265                ) );
    1266                 $c = self::$factory->term->create( array(
     1266                $c = self::factory()->term->create( array(
    12671267                        'taxonomy' => 'category',
    12681268                        'slug' => 'bar',
    12691269                ) );
    class Tests_Query_TaxQuery extends WP_UnitTestCase { 
    13011301         */
    13021302        public function test_populate_tag_id_query_var_from_tax_query() {
    13031303                register_taxonomy( 'foo', 'post' );
    1304                 $t = self::$factory->term->create( array(
     1304                $t = self::factory()->term->create( array(
    13051305                        'taxonomy' => 'foo',
    13061306                ) );
    1307                 $tag = self::$factory->term->create( array(
     1307                $tag = self::factory()->term->create( array(
    13081308                        'taxonomy' => 'post_tag',
    13091309                        'slug' => 'bar',
    13101310                ) );
  • tests/phpunit/tests/rest-api/rest-server.php

    diff --git tests/phpunit/tests/rest-api/rest-server.php tests/phpunit/tests/rest-api/rest-server.php
    index bd0abb3..2ec561a 100644
    class Tests_REST_Server extends WP_Test_REST_TestCase { 
    136136                        'permission_callback' => '__return_true',
    137137                ) );
    138138
    139                 $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     139                $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    140140
    141141                $request = new WP_REST_Request( 'GET', '/test-ns/test', array() );
    142142
  • tests/phpunit/tests/rewrite.php

    diff --git tests/phpunit/tests/rewrite.php tests/phpunit/tests/rewrite.php
    index 2f60b34..338cb9b 100644
    class Tests_Rewrite extends WP_UnitTestCase { 
    8585
    8686        function test_url_to_postid() {
    8787
    88                 $id = self::$factory->post->create();
     88                $id = self::factory()->post->create();
    8989                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    9090
    91                 $id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     91                $id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    9292                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    9393        }
    9494
    9595        function test_url_to_postid_set_url_scheme_https_to_http() {
    96                 $post_id = self::$factory->post->create();
     96                $post_id = self::factory()->post->create();
    9797                $permalink = get_permalink( $post_id );
    9898                $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) );
    9999
    100                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     100                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    101101                $permalink = get_permalink( $post_id );
    102102                $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) );
    103103        }
    class Tests_Rewrite extends WP_UnitTestCase { 
    109109
    110110                $_SERVER['HTTPS'] = 'on';
    111111
    112                 $post_id = self::$factory->post->create();
     112                $post_id = self::factory()->post->create();
    113113                $permalink = get_permalink( $post_id );
    114114                $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
    115115
    116                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     116                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    117117                $permalink = get_permalink( $post_id );
    118118                $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) );
    119119
    class Tests_Rewrite extends WP_UnitTestCase { 
    128128                $post_type = rand_str( 12 );
    129129                register_post_type( $post_type, array( 'public' => true ) );
    130130
    131                 $id = self::$factory->post->create( array( 'post_type' => $post_type ) );
     131                $id = self::factory()->post->create( array( 'post_type' => $post_type ) );
    132132                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    133133
    134134                _unregister_post_type( $post_type );
    class Tests_Rewrite extends WP_UnitTestCase { 
    136136
    137137        function test_url_to_postid_hierarchical() {
    138138
    139                 $parent_id = self::$factory->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) );
    140                 $child_id = self::$factory->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) );
     139                $parent_id = self::factory()->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) );
     140                $child_id = self::factory()->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) );
    141141
    142142                $this->assertEquals( $parent_id, url_to_postid( get_permalink( $parent_id ) ) );
    143143                $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) );
    class Tests_Rewrite extends WP_UnitTestCase { 
    145145
    146146        function test_url_to_postid_hierarchical_with_matching_leaves() {
    147147
    148                 $parent_id = self::$factory->post->create( array(
     148                $parent_id = self::factory()->post->create( array(
    149149                        'post_name' => 'parent',
    150150                        'post_type' => 'page',
    151151                ) );
    152                 $child_id_1 = self::$factory->post->create( array(
     152                $child_id_1 = self::factory()->post->create( array(
    153153                        'post_name'   => 'child1',
    154154                        'post_type'   => 'page',
    155155                        'post_parent' => $parent_id,
    156156                ) );
    157                 $child_id_2 = self::$factory->post->create( array(
     157                $child_id_2 = self::factory()->post->create( array(
    158158                        'post_name'   => 'child2',
    159159                        'post_type'   => 'page',
    160160                        'post_parent' => $parent_id,
    161161                ) );
    162                 $grandchild_id_1 = self::$factory->post->create( array(
     162                $grandchild_id_1 = self::factory()->post->create( array(
    163163                        'post_name'   => 'grandchild',
    164164                        'post_type'   => 'page',
    165165                        'post_parent' => $child_id_1,
    166166                ) );
    167                 $grandchild_id_2 = self::$factory->post->create( array(
     167                $grandchild_id_2 = self::factory()->post->create( array(
    168168                        'post_name'   => 'grandchild',
    169169                        'post_type'   => 'page',
    170170                        'post_parent' => $child_id_2,
    class Tests_Rewrite extends WP_UnitTestCase { 
    180180
    181181                update_option( 'home', home_url( '/example/' ) );
    182182
    183                 $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) );
     183                $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) );
    184184                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    185185                $this->assertEquals( $id, url_to_postid( site_url('/example/examp' ) ) );
    186186                $this->assertEquals( $id, url_to_postid( '/example/examp/' ) );
    class Tests_Rewrite extends WP_UnitTestCase { 
    244244        function test_url_to_postid_dupe_path() {
    245245                update_option( 'home', home_url('/example/') );
    246246
    247                 $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) );
     247                $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) );
    248248
    249249                $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
    250250                $this->assertEquals( $id, url_to_postid( site_url( '/example/example/' ) ) );
    class Tests_Rewrite extends WP_UnitTestCase { 
    258258        function test_url_to_postid_home_url_collision() {
    259259                update_option( 'home', home_url( '/example' ) );
    260260
    261                 self::$factory->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) );
     261                self::factory()->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) );
    262262
    263263                // This url should NOT return a post ID
    264264                $badurl = site_url( '/example-collision' );
    class Tests_Rewrite extends WP_UnitTestCase { 
    277277                        return false;
    278278                }
    279279
    280                 $blog_id = self::$factory->blog->create( array( 'path' => '/example' ) );
     280                $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) );
    281281                switch_to_blog( $blog_id );
    282282
    283                 self::$factory->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) );
     283                self::factory()->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) );
    284284
    285285                // This url should NOT return a post ID
    286286                $badurl = network_home_url( '/example-collision' );
    class Tests_Rewrite extends WP_UnitTestCase { 
    294294         */
    295295        public function test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() {
    296296
    297                 $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     297                $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    298298                update_option( 'show_on_front', 'page' );
    299299                update_option( 'page_on_front', $page_id );
    300300
    class Tests_Rewrite extends WP_UnitTestCase { 
    313313        function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() {
    314314                $this->set_permalink_structure( '/%postname%/' );
    315315
    316                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) );
    317                 $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) );
     316                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) );
     317                $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) );
    318318
    319319                $this->assertEquals( $post_id, url_to_postid( get_permalink( $post_id ) ) );
    320320
    class Tests_Rewrite extends WP_UnitTestCase { 
    327327        function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() {
    328328                $this->set_permalink_structure( '/%postname%/' );
    329329
    330                 $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) );
    331                 $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) );
     330                $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) );
     331                $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) );
    332332
    333333                $this->go_to( get_permalink( $post_id ) );
    334334
  • tests/phpunit/tests/rewrite/numericSlugs.php

    diff --git tests/phpunit/tests/rewrite/numericSlugs.php tests/phpunit/tests/rewrite/numericSlugs.php
    index 652b28b..3f7aa11 100644
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    99
    1010        public function setUp() {
    1111                parent::setUp();
    12                 $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     12                $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1313
    1414                // Override the post/archive slug collision prevention in `wp_unique_post_slug()`.
    1515                add_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ), 10, 6 );
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    2323                global $wpdb;
    2424                $this->set_permalink_structure( '/%postname%/' );
    2525
    26                 $id = self::$factory->post->create( array(
     26                $id = self::factory()->post->create( array(
    2727                        'post_author'  => $this->author_id,
    2828                        'post_status'  => 'publish',
    2929                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    5151                global $wpdb;
    5252                $this->set_permalink_structure( '/%postname%/' );
    5353
    54                 $id = self::$factory->post->create( array(
     54                $id = self::factory()->post->create( array(
    5555                        'post_author'  => $this->author_id,
    5656                        'post_status'  => 'publish',
    5757                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    7676        public function test_go_to_year_segment_collision_with_title() {
    7777                $this->set_permalink_structure( '/%postname%/' );
    7878
    79                 $id = self::$factory->post->create( array(
     79                $id = self::factory()->post->create( array(
    8080                        'post_author'  => $this->author_id,
    8181                        'post_status'  => 'publish',
    8282                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    9292        public function test_url_to_postid_year_segment_collision_with_title() {
    9393                $this->set_permalink_structure( '/%postname%/' );
    9494
    95                 $id = self::$factory->post->create( array(
     95                $id = self::factory()->post->create( array(
    9696                        'post_author'  => $this->author_id,
    9797                        'post_status'  => 'publish',
    9898                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    106106        public function test_go_to_month_segment_collision_without_title() {
    107107                $this->set_permalink_structure( '/%year%/%postname%/' );
    108108
    109                 $id = self::$factory->post->create( array(
     109                $id = self::factory()->post->create( array(
    110110                        'post_author'  => $this->author_id,
    111111                        'post_status'  => 'publish',
    112112                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    123123        public function test_url_to_postid_month_segment_collision_without_title() {
    124124                $this->set_permalink_structure( '/%year%/%postname%/' );
    125125
    126                 $id = self::$factory->post->create( array(
     126                $id = self::factory()->post->create( array(
    127127                        'post_author'  => $this->author_id,
    128128                        'post_status'  => 'publish',
    129129                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    138138        public function test_go_to_month_segment_collision_without_title_no_leading_zero() {
    139139                $this->set_permalink_structure( '/%year%/%postname%/' );
    140140
    141                 $id = self::$factory->post->create( array(
     141                $id = self::factory()->post->create( array(
    142142                        'post_author'  => $this->author_id,
    143143                        'post_status'  => 'publish',
    144144                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    155155        public function test_url_to_postid_month_segment_collision_without_title_no_leading_zero() {
    156156                $this->set_permalink_structure( '/%year%/%postname%/' );
    157157
    158                 $id = self::$factory->post->create( array(
     158                $id = self::factory()->post->create( array(
    159159                        'post_author'  => $this->author_id,
    160160                        'post_status'  => 'publish',
    161161                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    170170        public function test_go_to_month_segment_collision_with_title() {
    171171                $this->set_permalink_structure( '/%year%/%postname%/' );
    172172
    173                 $id = self::$factory->post->create( array(
     173                $id = self::factory()->post->create( array(
    174174                        'post_author'  => $this->author_id,
    175175                        'post_status'  => 'publish',
    176176                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    186186        public function test_url_to_postid_month_segment_collision_with_title() {
    187187                $this->set_permalink_structure( '/%year%/%postname%/' );
    188188
    189                 $id = self::$factory->post->create( array(
     189                $id = self::factory()->post->create( array(
    190190                        'post_author'  => $this->author_id,
    191191                        'post_status'  => 'publish',
    192192                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    200200        public function test_go_to_month_segment_collision_with_title_no_leading_zero() {
    201201                $this->set_permalink_structure( '/%year%/%postname%/' );
    202202
    203                 $id = self::$factory->post->create( array(
     203                $id = self::factory()->post->create( array(
    204204                        'post_author'  => $this->author_id,
    205205                        'post_status'  => 'publish',
    206206                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    216216        public function test_url_to_postid_month_segment_collision_with_title_no_leading_zero() {
    217217                $this->set_permalink_structure( '/%year%/%postname%/' );
    218218
    219                 $id = self::$factory->post->create( array(
     219                $id = self::factory()->post->create( array(
    220220                        'post_author'  => $this->author_id,
    221221                        'post_status'  => 'publish',
    222222                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    230230        public function test_go_to_day_segment_collision_without_title() {
    231231                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    232232
    233                 $id = self::$factory->post->create( array(
     233                $id = self::factory()->post->create( array(
    234234                        'post_author'  => $this->author_id,
    235235                        'post_status'  => 'publish',
    236236                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    247247        public function test_url_to_postid_day_segment_collision_without_title() {
    248248                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    249249
    250                 $id = self::$factory->post->create( array(
     250                $id = self::factory()->post->create( array(
    251251                        'post_author'  => $this->author_id,
    252252                        'post_status'  => 'publish',
    253253                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    262262        public function test_go_to_day_segment_collision_with_title() {
    263263                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    264264
    265                 $id = self::$factory->post->create( array(
     265                $id = self::factory()->post->create( array(
    266266                        'post_author'  => $this->author_id,
    267267                        'post_status'  => 'publish',
    268268                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    278278        public function test_url_to_postid_day_segment_collision_with_title() {
    279279                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    280280
    281                 $id = self::$factory->post->create( array(
     281                $id = self::factory()->post->create( array(
    282282                        'post_author'  => $this->author_id,
    283283                        'post_status'  => 'publish',
    284284                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    292292        public function test_numeric_slug_permalink_conflicts_should_only_be_resolved_for_the_main_query() {
    293293                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    294294
    295                 $id = self::$factory->post->create( array(
     295                $id = self::factory()->post->create( array(
    296296                        'post_author'  => $this->author_id,
    297297                        'post_status'  => 'publish',
    298298                        'post_content' => rand_str(),
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    314314                $this->set_permalink_structure( '/%year%/%postname%/' );
    315315
    316316                // Make sure a post is published in 2013/02, to avoid 404s.
    317                 self::$factory->post->create( array(
     317                self::factory()->post->create( array(
    318318                        'post_author'  => $this->author_id,
    319319                        'post_status'  => 'publish',
    320320                        'post_content' => 'foo',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    322322                        'post_date'    => '2013-02-01 01:00:00',
    323323                ) );
    324324
    325                 $id = self::$factory->post->create( array(
     325                $id = self::factory()->post->create( array(
    326326                        'post_author'  => $this->author_id,
    327327                        'post_status'  => 'publish',
    328328                        'post_content' => 'foo',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    342342                $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
    343343
    344344                // Make sure a post is published on 2015/01/01, to avoid 404s.
    345                 self::$factory->post->create( array(
     345                self::factory()->post->create( array(
    346346                        'post_author'  => $this->author_id,
    347347                        'post_status'  => 'publish',
    348348                        'post_content' => 'foo',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    350350                        'post_date'    => '2015-01-02 01:00:00',
    351351                ) );
    352352
    353                 $id = self::$factory->post->create( array(
     353                $id = self::factory()->post->create( array(
    354354                        'post_author'  => $this->author_id,
    355355                        'post_status'  => 'publish',
    356356                        'post_content' => 'foo',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    369369        public function test_date_slug_collision_should_distinguish_valid_pagination_from_date() {
    370370                $this->set_permalink_structure( '/%year%/%postname%/' );
    371371
    372                 $id = self::$factory->post->create( array(
     372                $id = self::factory()->post->create( array(
    373373                        'post_author'  => $this->author_id,
    374374                        'post_status'  => 'publish',
    375375                        'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    385385        public function test_date_slug_collision_should_distinguish_too_high_pagination_from_date() {
    386386                $this->set_permalink_structure( '/%year%/%postname%/' );
    387387
    388                 $id = self::$factory->post->create( array(
     388                $id = self::factory()->post->create( array(
    389389                        'post_author'  => $this->author_id,
    390390                        'post_status'  => 'publish',
    391391                        'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    401401        public function test_date_slug_collision_should_not_require_pagination_query_var() {
    402402                $this->set_permalink_structure( '/%year%/%postname%/' );
    403403
    404                 $id = self::$factory->post->create( array(
     404                $id = self::factory()->post->create( array(
    405405                        'post_author'  => $this->author_id,
    406406                        'post_status'  => 'publish',
    407407                        'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
    class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { 
    418418        public function test_date_slug_collision_should_be_ignored_when_pagination_var_is_present_but_post_does_not_have_multiple_pages() {
    419419                $this->set_permalink_structure( '/%year%/%postname%/' );
    420420
    421                 $id = self::$factory->post->create( array(
     421                $id = self::factory()->post->create( array(
    422422                        'post_author'  => $this->author_id,
    423423                        'post_status'  => 'publish',
    424424                        'post_content' => 'This post does not have pagination.',
  • tests/phpunit/tests/rewrite/oldSlugRedirect.php

    diff --git tests/phpunit/tests/rewrite/oldSlugRedirect.php tests/phpunit/tests/rewrite/oldSlugRedirect.php
    index 97c187c..7192013 100644
    class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { 
    1212        public function setUp() {
    1313                parent::setUp();
    1414
    15                 $this->post_id = self::$factory->post->create( array(
     15                $this->post_id = self::factory()->post->create( array(
    1616                        'post_title'   => 'Foo Bar',
    1717                        'post_name'   => 'foo-bar',
    1818                ) );
    class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { 
    9999
    100100        public function test_old_slug_redirect_attachment() {
    101101                $file          = DIR_TESTDATA . '/images/canola.jpg';
    102                 $attachment_id = self::$factory->attachment->create_object( $file, $this->post_id, array(
     102                $attachment_id = self::factory()->attachment->create_object( $file, $this->post_id, array(
    103103                        'post_mime_type' => 'image/jpeg',
    104104                        'post_name'      => 'my-attachment',
    105105                ) );
  • tests/phpunit/tests/taxonomy.php

    diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
    index 6c0447f..7f49fc2 100644
    class Tests_Taxonomy extends WP_UnitTestCase { 
    3434        }
    3535
    3636        function test_get_the_taxonomies() {
    37                 $post_id = self::$factory->post->create();
     37                $post_id = self::factory()->post->create();
    3838
    3939                $taxes = get_the_taxonomies( $post_id );
    4040                $this->assertNotEmpty( $taxes );
    4141                $this->assertEquals( array( 'category' ), array_keys( $taxes ) );
    4242
    43                 $id = self::$factory->tag->create();
     43                $id = self::factory()->tag->create();
    4444                wp_set_post_tags( $post_id, array( $id ) );
    4545
    4646                $taxes = get_the_taxonomies( $post_id );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    5353         * @group 27238
    5454         */
    5555        public function test_get_the_taxonomies_term_template() {
    56                 $post_id = self::$factory->post->create();
     56                $post_id = self::factory()->post->create();
    5757
    5858                $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '%2$s' ) );
    5959                $this->assertEquals( 'Categories: Uncategorized.', $taxes['category'] );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    6464        }
    6565
    6666        function test_the_taxonomies() {
    67                 $post_id = self::$factory->post->create();
     67                $post_id = self::factory()->post->create();
    6868
    6969                ob_start();
    7070                the_taxonomies( array( 'post' => $post_id ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    7979         * @group 27238
    8080         */
    8181        function test_the_taxonomies_term_template() {
    82                 $post_id = self::$factory->post->create();
     82                $post_id = self::factory()->post->create();
    8383
    8484                $output = get_echo( 'the_taxonomies', array( array( 'post' => $post_id, 'term_template' => '%2$s' ) ) );
    8585                $this->assertEquals( 'Categories: Uncategorized.', $output );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    262262        }
    263263
    264264        public function test_get_objects_in_term_should_return_objects_ids() {
    265                 $tag_id = self::$factory->tag->create();
    266                 $cat_id = self::$factory->category->create();
     265                $tag_id = self::factory()->tag->create();
     266                $cat_id = self::factory()->category->create();
    267267                $posts_with_tag = array();
    268268                $posts_with_category = array();
    269269
    270270                for ( $i = 0; $i < 3; $i++ ) {
    271                         $post_id = self::$factory->post->create();
     271                        $post_id = self::factory()->post->create();
    272272                        wp_set_post_tags( $post_id, array( $tag_id ) );
    273273                        $posts_with_tag[] = $post_id;
    274274                }
    275275
    276276                for ( $i = 0; $i < 3; $i++ ) {
    277                         $post_id = self::$factory->post->create();
     277                        $post_id = self::factory()->post->create();
    278278                        wp_set_post_categories( $post_id, array( $cat_id ) );
    279279                        $posts_with_category[] = $post_id;
    280280                }
    281281
    282282                for ( $i = 0; $i < 3; $i++ ) {
    283                         self::$factory->post->create();
     283                        self::factory()->post->create();
    284284                }
    285285
    286286                $posts_with_terms = array_merge( $posts_with_tag, $posts_with_category );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    295295         * @ticket 25706
    296296         */
    297297        function test_in_category() {
    298                 $post = self::$factory->post->create_and_get();
     298                $post = self::factory()->post->create_and_get();
    299299
    300300                // in_category() returns false when first parameter is empty()
    301301                $this->assertFalse( in_category( '', $post ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    346346
    347347        public function test_get_ancestors_taxonomy_non_hierarchical() {
    348348                register_taxonomy( 'wptests_tax', 'post' );
    349                 $t = self::$factory->term->create( array(
     349                $t = self::factory()->term->create( array(
    350350                        'taxonomy' => 'wptests_tax',
    351351                ) );
    352352
    class Tests_Taxonomy extends WP_UnitTestCase { 
    358358                register_taxonomy( 'wptests_tax', 'post', array(
    359359                        'hierarchical' => true,
    360360                ) );
    361                 $t1 = self::$factory->term->create( array(
     361                $t1 = self::factory()->term->create( array(
    362362                        'taxonomy' => 'wptests_tax',
    363363                ) );
    364                 $t2 = self::$factory->term->create( array(
     364                $t2 = self::factory()->term->create( array(
    365365                        'taxonomy' => 'wptests_tax',
    366366                        'parent' => $t1,
    367367                ) );
    368                 $t3 = self::$factory->term->create( array(
     368                $t3 = self::factory()->term->create( array(
    369369                        'taxonomy' => 'wptests_tax',
    370370                        'parent' => $t2,
    371371                ) );
    372                 $t4 = self::$factory->term->create( array(
     372                $t4 = self::factory()->term->create( array(
    373373                        'taxonomy' => 'wptests_tax',
    374374                        'parent' => $t1,
    375375                ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    380380
    381381        public function test_get_ancestors_post_type_non_hierarchical() {
    382382                register_post_type( 'wptests_pt' );
    383                 $p = self::$factory->post->create( array(
     383                $p = self::factory()->post->create( array(
    384384                        'taxonomy' => 'wptests_pt',
    385385                ) );
    386386
    class Tests_Taxonomy extends WP_UnitTestCase { 
    391391                register_post_type( 'wptests_pt', array(
    392392                        'hierarchical' => true,
    393393                ) );
    394                 $p1 = self::$factory->post->create( array(
     394                $p1 = self::factory()->post->create( array(
    395395                        'post_type' => 'wptests_pt',
    396396                ) );
    397                 $p2 = self::$factory->post->create( array(
     397                $p2 = self::factory()->post->create( array(
    398398                        'post_type' => 'wptests_pt',
    399399                        'post_parent' => $p1,
    400400                ) );
    401                 $p3 = self::$factory->post->create( array(
     401                $p3 = self::factory()->post->create( array(
    402402                        'post_type' => 'wptests_pt',
    403403                        'post_parent' => $p2,
    404404                ) );
    405                 $p4 = self::$factory->post->create( array(
     405                $p4 = self::factory()->post->create( array(
    406406                        'post_type' => 'wptests_pt',
    407407                        'post_parent' => $p1,
    408408                ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    418418                register_post_type( 'wptests_conflict', array(
    419419                        'hierarchical' => true,
    420420                ) );
    421                 $p1 = self::$factory->post->create( array(
     421                $p1 = self::factory()->post->create( array(
    422422                        'post_type' => 'wptests_conflict',
    423423                ) );
    424                 $p2 = self::$factory->post->create( array(
     424                $p2 = self::factory()->post->create( array(
    425425                        'post_type' => 'wptests_conflict',
    426426                        'post_parent' => $p1,
    427427                ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    429429                register_taxonomy( 'wptests_conflict', 'post', array(
    430430                        'hierarchical' => true,
    431431                ) );
    432                 $t1 = self::$factory->term->create( array(
     432                $t1 = self::factory()->term->create( array(
    433433                        'taxonomy' => 'wptests_conflict',
    434434                ) );
    435                 $t2 = self::$factory->term->create( array(
     435                $t2 = self::factory()->term->create( array(
    436436                        'taxonomy' => 'wptests_conflict',
    437437                        'parent' => $t1,
    438438                ) );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    451451                        'public' => false,
    452452                ) );
    453453
    454                 $t = self::$factory->term->create_and_get( array(
     454                $t = self::factory()->term->create_and_get( array(
    455455                        'taxonomy' => 'wptests_tax',
    456456                ) );
    457457
    458                 $p = self::$factory->post->create();
     458                $p = self::factory()->post->create();
    459459                wp_set_object_terms( $p, $t->slug, 'wptests_tax' );
    460460
    461461                $this->go_to( '/?wptests_tax=' . $t->slug );
    class Tests_Taxonomy extends WP_UnitTestCase { 
    471471                        'public' => false,
    472472                ) );
    473473
    474                 $t = self::$factory->term->create_and_get( array(
     474                $t = self::factory()->term->create_and_get( array(
    475475                        'taxonomy' => 'wptests_tax',
    476476                ) );
    477477
    478                 $p = self::$factory->post->create();
     478                $p = self::factory()->post->create();
    479479                wp_set_object_terms( $p, $t->slug, 'wptests_tax' );
    480480
    481481                $this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug );
  • tests/phpunit/tests/term.php

    diff --git tests/phpunit/tests/term.php tests/phpunit/tests/term.php
    index 1c76e96..ca5b79a 100644
    class Tests_Term extends WP_UnitTestCase { 
    2323                        'hierarchical' => true,
    2424                ) );
    2525
    26                 $parent = self::$factory->term->create( array(
     26                $parent = self::factory()->term->create( array(
    2727                        'taxonomy' => 'wptests_tax',
    2828                ) );
    2929
    30                 $child = self::$factory->term->create( array(
     30                $child = self::factory()->term->create( array(
    3131                        'taxonomy' => 'wptests_tax',
    3232                        'parent' => $parent,
    3333                        'slug' => 'foo',
    class Tests_Term extends WP_UnitTestCase { 
    226226        public function test_wp_set_object_terms_append_true() {
    227227                register_taxonomy( 'wptests_tax', 'post' );
    228228                $p = self::$post_ids[0];
    229                 $t1 = self::$factory->term->create( array(
     229                $t1 = self::factory()->term->create( array(
    230230                        'taxonomy' => 'wptests_tax',
    231231                ) );
    232                 $t2 = self::$factory->term->create( array(
     232                $t2 = self::factory()->term->create( array(
    233233                        'taxonomy' => 'wptests_tax',
    234234                ) );
    235235
    class Tests_Term extends WP_UnitTestCase { 
    247247        public function test_wp_set_object_terms_append_false() {
    248248                register_taxonomy( 'wptests_tax', 'post' );
    249249                $p = self::$post_ids[0];
    250                 $t1 = self::$factory->term->create( array(
     250                $t1 = self::factory()->term->create( array(
    251251                        'taxonomy' => 'wptests_tax',
    252252                ) );
    253                 $t2 = self::$factory->term->create( array(
     253                $t2 = self::factory()->term->create( array(
    254254                        'taxonomy' => 'wptests_tax',
    255255                ) );
    256256
    class Tests_Term extends WP_UnitTestCase { 
    268268        public function test_wp_set_object_terms_append_default_to_false() {
    269269                register_taxonomy( 'wptests_tax', 'post' );
    270270                $p = self::$post_ids[0];
    271                 $t1 = self::$factory->term->create( array(
     271                $t1 = self::factory()->term->create( array(
    272272                        'taxonomy' => 'wptests_tax',
    273273                ) );
    274                 $t2 = self::$factory->term->create( array(
     274                $t2 = self::factory()->term->create( array(
    275275                        'taxonomy' => 'wptests_tax',
    276276                ) );
    277277
    class Tests_Term extends WP_UnitTestCase { 
    364364         */
    365365        function test_wp_add_remove_object_terms() {
    366366                $posts = self::$post_ids;
    367                 $tags = self::$factory->tag->create_many( 5 );
     367                $tags = self::factory()->tag->create_many( 5 );
    368368
    369369                $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' );
    370370                $this->assertEquals( 1, count( $tt ) );
    class Tests_Term extends WP_UnitTestCase { 
    523523         */
    524524        function test_object_term_cache_when_term_changes() {
    525525                $post_id = self::$post_ids[0];
    526                 $tag_id = self::$factory->tag->create( array(
     526                $tag_id = self::factory()->tag->create( array(
    527527                        'name' => 'Amaze Tag',
    528528                        'description' => 'My Amazing Tag'
    529529                ) );
    class Tests_Term extends WP_UnitTestCase { 
    553553        public function test_get_the_terms_should_not_cache_wp_term_objects() {
    554554                $p = self::$post_ids[0];
    555555                register_taxonomy( 'wptests_tax', 'post' );
    556                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     556                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    557557                wp_set_object_terms( $p, $t, 'wptests_tax' );
    558558
    559559                // Prime the cache.
    class Tests_Term extends WP_UnitTestCase { 
    572572        public function test_get_the_terms_should_return_wp_term_objects_from_cache() {
    573573                $p = self::$post_ids[0];
    574574                register_taxonomy( 'wptests_tax', 'post' );
    575                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     575                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    576576                wp_set_object_terms( $p, $t, 'wptests_tax' );
    577577
    578578                // Prime the cache.
    class Tests_Term extends WP_UnitTestCase { 
    618618         * @ticket 19205
    619619         */
    620620        function test_orphan_category() {
    621                 $cat_id1 = self::$factory->category->create();
     621                $cat_id1 = self::factory()->category->create();
    622622
    623623                wp_delete_category( $cat_id1 );
    624624
    625                 $cat_id2 = self::$factory->category->create( array( 'parent' => $cat_id1 ) );
     625                $cat_id2 = self::factory()->category->create( array( 'parent' => $cat_id1 ) );
    626626                $this->assertWPError( $cat_id2 );
    627627        }
    628628}
  • tests/phpunit/tests/term/cache.php

    diff --git tests/phpunit/tests/term/cache.php tests/phpunit/tests/term/cache.php
    index 088a7fe..828917a 100644
    class Tests_Term_Cache extends WP_UnitTestCase { 
    1515         */
    1616        function test_category_children_cache() {
    1717                // Test with only one Parent => Child
    18                 $term_id1 = self::$factory->category->create();
    19                 $term_id1_child = self::$factory->category->create( array( 'parent' => $term_id1 ) );
     18                $term_id1 = self::factory()->category->create();
     19                $term_id1_child = self::factory()->category->create( array( 'parent' => $term_id1 ) );
    2020                $hierarchy = _get_term_hierarchy( 'category' );
    2121
    2222                $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy );
    2323
    2424                // Add another Parent => Child
    25                 $term_id2 = self::$factory->category->create();
    26                 $term_id2_child = self::$factory->category->create( array( 'parent' => $term_id2 ) );
     25                $term_id2 = self::factory()->category->create();
     26                $term_id2_child = self::factory()->category->create( array( 'parent' => $term_id2 ) );
    2727                $hierarchy = _get_term_hierarchy( 'category' );
    2828
    2929                $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy );
    class Tests_Term_Cache extends WP_UnitTestCase { 
    3333         * @ticket 22526
    3434         */
    3535        function test_category_name_change() {
    36                 $term = self::$factory->category->create_and_get( array( 'name' => 'Foo' ) );
    37                 $post_id = self::$factory->post->create();
     36                $term = self::factory()->category->create_and_get( array( 'name' => 'Foo' ) );
     37                $post_id = self::factory()->post->create();
    3838                wp_set_post_categories( $post_id, $term->term_id );
    3939
    4040                $post = get_post( $post_id );
    class Tests_Term_Cache extends WP_UnitTestCase { 
    9898                global $wpdb;
    9999
    100100                register_taxonomy( 'wptests_tax', 'post' );
    101                 $term = self::$factory->term->create( array(
     101                $term = self::factory()->term->create( array(
    102102                        'taxonomy' => 'wptests_tax',
    103103                ) );
    104104
    class Tests_Term_Cache extends WP_UnitTestCase { 
    124124                global $wpdb;
    125125
    126126                register_taxonomy( 'wptests_tax', 'post' );
    127                 $term = self::$factory->term->create( array(
     127                $term = self::factory()->term->create( array(
    128128                        'taxonomy' => 'wptests_tax',
    129129                ) );
    130130
    class Tests_Term_Cache extends WP_UnitTestCase { 
    151151                global $wpdb;
    152152
    153153                register_taxonomy( 'wptests_tax', 'post' );
    154                 $term = self::$factory->term->create( array(
     154                $term = self::factory()->term->create( array(
    155155                        'taxonomy' => 'wptests_tax',
    156156                ) );
    157157
    class Tests_Term_Cache extends WP_UnitTestCase { 
    182182
    183183                register_taxonomy( 'wptests_tax', 'post' );
    184184
    185                 $terms = self::$factory->term->create_many( 5, array(
     185                $terms = self::factory()->term->create_many( 5, array(
    186186                        'taxonomy' => 'wptests_tax',
    187187                ) );
    188188
  • tests/phpunit/tests/term/categoryExists.php

    diff --git tests/phpunit/tests/term/categoryExists.php tests/phpunit/tests/term/categoryExists.php
    index ff1e39d..a44ed1f 100644
    class Tests_Term_CategoryExists extends WP_UnitTestCase { 
    55         * @ticket 30975
    66         */
    77        public function test_category_exists_should_return_only_top_level_categories_when_parent_is_0() {
    8                 $c1 = self::$factory->category->create();
    9                 $c2 = self::$factory->category->create( array(
     8                $c1 = self::factory()->category->create();
     9                $c2 = self::factory()->category->create( array(
    1010                        'name' => 'Foo',
    1111                        'parent' => $c1,
    1212                ) );
    13                 $c3 = self::$factory->category->create( array(
     13                $c3 = self::factory()->category->create( array(
    1414                        'name' => 'Foo',
    1515                ) );
    1616
    class Tests_Term_CategoryExists extends WP_UnitTestCase { 
    2424         */
    2525        public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_1() {
    2626                // Foo child of c1 is created first.
    27                 $c1 = self::$factory->category->create();
    28                 $c2 = self::$factory->category->create( array(
     27                $c1 = self::factory()->category->create();
     28                $c2 = self::factory()->category->create( array(
    2929                        'name' => 'Foo',
    3030                        'parent' => $c1,
    3131                ) );
    32                 $c3 = self::$factory->category->create( array(
     32                $c3 = self::factory()->category->create( array(
    3333                        'name' => 'Foo',
    3434                ) );
    3535
    class Tests_Term_CategoryExists extends WP_UnitTestCase { 
    4343         */
    4444        public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_2() {
    4545                // Top-level Foo is created first.
    46                 $c1 = self::$factory->category->create();
    47                 $c2 = self::$factory->category->create( array(
     46                $c1 = self::factory()->category->create();
     47                $c2 = self::factory()->category->create( array(
    4848                        'name' => 'Foo',
    4949                ) );
    50                 $c3 = self::$factory->category->create( array(
     50                $c3 = self::factory()->category->create( array(
    5151                        'name' => 'Foo',
    5252                        'parent' => $c1,
    5353                ) );
    class Tests_Term_CategoryExists extends WP_UnitTestCase { 
    6161         * @ticket 30975
    6262         */
    6363        public function test_category_exists_should_respect_nonempty_parent() {
    64                 $c1 = self::$factory->category->create();
    65                 $c2 = self::$factory->category->create( array(
     64                $c1 = self::factory()->category->create();
     65                $c2 = self::factory()->category->create( array(
    6666                        'name' => 'Foo',
    6767                        'parent' => $c1,
    6868                ) );
    69                 $c3 = self::$factory->category->create( array(
     69                $c3 = self::factory()->category->create( array(
    7070                        'name' => 'Foo',
    7171                ) );
    7272
  • tests/phpunit/tests/term/getEditTermLink.php

    diff --git tests/phpunit/tests/term/getEditTermLink.php tests/phpunit/tests/term/getEditTermLink.php
    index 3fa0ae1..b4a0ec8 100644
     
    66class Tests_Term_GetEditTermLink extends WP_UnitTestCase {
    77        public function setUp() {
    88                parent::setUp();
    9                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     9                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    1010                register_taxonomy( 'wptests_tax', 'post' );
    1111        }
    1212
    1313        public function test_get_edit_term_link_default() {
    14                 $term1 = self::$factory->term->create( array(
     14                $term1 = self::factory()->term->create( array(
    1515                        'taxonomy' => 'wptests_tax',
    1616                        'name' => 'foo',
    1717                ) );
    class Tests_Term_GetEditTermLink extends WP_UnitTestCase { 
    2525         * @ticket 32786
    2626         */
    2727        public function test_get_edit_term_link_invalid_id() {
    28                 $term1 = self::$factory->term->create( array(
     28                $term1 = self::factory()->term->create( array(
    2929                        'taxonomy' => 'wptests_tax',
    3030                        'name' => 'foo',
    3131                ) );
  • tests/phpunit/tests/term/getTerm.php

    diff --git tests/phpunit/tests/term/getTerm.php tests/phpunit/tests/term/getTerm.php
    index 1a6f8fd..4ad45a1 100644
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    2424        public function test_passing_term_object_should_skip_database_query_when_filter_property_is_empty() {
    2525                global $wpdb;
    2626
    27                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
     27                $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) );
    2828                clean_term_cache( $term->term_id, 'wptests_tax' );
    2929
    3030                $num_queries = $wpdb->num_queries;
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    4646        public function test_cache_should_be_populated_by_successful_fetch() {
    4747                global $wpdb;
    4848
    49                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     49                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    5050                clean_term_cache( $t, 'wptests_tax' );
    5151
    5252                // Prime cache.
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    6060        }
    6161
    6262        public function test_output_object() {
    63                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     63                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    6464                $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', OBJECT ) );
    6565        }
    6666
    6767        public function test_output_array_a() {
    68                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     68                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    6969                $term = get_term( $t, 'wptests_tax', ARRAY_A );
    7070                $this->assertInternalType( 'array', $term );
    7171                $this->assertTrue( isset( $term['term_id'] ) );
    7272        }
    7373
    7474        public function test_output_array_n() {
    75                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     75                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    7676                $term = get_term( $t, 'wptests_tax', ARRAY_N );
    7777                $this->assertInternalType( 'array', $term );
    7878                $this->assertFalse( isset( $term['term_id'] ) );
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    8282        }
    8383
    8484        public function test_output_should_fall_back_to_object_for_invalid_input() {
    85                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     85                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    8686                $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', 'foo' ) );
    8787        }
    8888
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    9292        public function test_numeric_properties_should_be_cast_to_ints() {
    9393                global $wpdb;
    9494
    95                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     95                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    9696
    9797                // Get raw data from the database.
    9898                $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $t ) );
    class Tests_Term_GetTerm extends WP_UnitTestCase { 
    111111         * @ticket 34332
    112112         */
    113113         public function test_should_return_null_when_provided_taxonomy_does_not_match_actual_term_taxonomy() {
    114                 $term_id = self::$factory->term->create( array( 'taxonomy' => 'post_tag' ) );
     114                $term_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) );
    115115                $this->assertNull( get_term( $term_id, 'category' ) );
    116116        }
    117117}
  • tests/phpunit/tests/term/getTermBy.php

    diff --git tests/phpunit/tests/term/getTermBy.php tests/phpunit/tests/term/getTermBy.php
    index 7d66b6e..9d80ab6 100644
    class Tests_Term_GetTermBy extends WP_UnitTestCase { 
    2828                register_taxonomy( 'wptests_tax', 'post' );
    2929
    3030                $slug = 'ńaș';
    31                 $t = self::$factory->term->create( array(
     31                $t = self::factory()->term->create( array(
    3232                        'slug' => $slug,
    3333                        'taxonomy' => 'wptests_tax',
    3434                ) );
    class Tests_Term_GetTermBy extends WP_UnitTestCase { 
    4444                global $wpdb;
    4545
    4646                register_taxonomy( 'wptests_tax', 'post' );
    47                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     47                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    4848                $term = get_term( $t, 'wptests_tax' );
    4949
    5050                $new_ttid = $term->term_taxonomy_id + 1;
    class Tests_Term_GetTermBy extends WP_UnitTestCase { 
    6767                global $wpdb;
    6868
    6969                register_taxonomy( 'wptests_tax', 'post' );
    70                 $t = self::$factory->term->create( array(
     70                $t = self::factory()->term->create( array(
    7171                        'taxonomy' => 'wptests_tax',
    7272                        'slug' => 'foo',
    7373                ) );
  • tests/phpunit/tests/term/getTermField.php

    diff --git tests/phpunit/tests/term/getTermField.php tests/phpunit/tests/term/getTermField.php
    index c616f41..a225acc 100644
    class Tests_Term_getTermField extends WP_UnitTestCase { 
    1717         * @ticket 34245
    1818         */
    1919        public function test_get_term_field_should_not_return_error_for_empty_taxonomy() {
    20                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
     20                $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
    2121
    2222                $found = get_term_field( 'taxonomy', $term->term_id, '' );
    2323                $this->assertNotWPError( $found );
    class Tests_Term_getTermField extends WP_UnitTestCase { 
    2828         * @ticket 34245
    2929         */
    3030        public function test_get_term_field_supplying_a_taxonomy() {
    31                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
     31                $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
    3232
    3333                $found = get_term_field( 'taxonomy', $term->term_id, $term->taxonomy );
    3434                $this->assertSame( $this->taxonomy, $found );
    class Tests_Term_getTermField extends WP_UnitTestCase { 
    3838         * @ticket 34245
    3939         */
    4040        public function test_get_term_field_supplying_no_taxonomy() {
    41                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
     41                $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
    4242
    4343                $found = get_term_field( 'taxonomy', $term->term_id );
    4444                $this->assertSame( $this->taxonomy, $found );
    class Tests_Term_getTermField extends WP_UnitTestCase { 
    4848         * @ticket 34245
    4949         */
    5050        public function test_get_term_field_should_accept_a_WP_Term_object_or_a_term_id() {
    51                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
     51                $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
    5252
    5353                $this->assertInstanceOf( 'WP_Term', $term );
    5454                $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) );
    class Tests_Term_getTermField extends WP_UnitTestCase { 
    5959         * @ticket 34245
    6060         */
    6161        public function test_get_term_field_invalid_taxonomy_should_return_WP_Error() {
    62                 $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
     62                $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) );
    6363
    6464                $found = get_term_field( 'taxonomy', $term, 'foo-taxonomy' );
    6565                $this->assertWPError( $found );
  • tests/phpunit/tests/term/getTermLink.php

    diff --git tests/phpunit/tests/term/getTermLink.php tests/phpunit/tests/term/getTermLink.php
    index bd6c987..45c31ec 100644
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    1212        }
    1313
    1414        public function test_integer_should_be_interpreted_as_term_id() {
    15                 $t1 = self::$factory->term->create( array(
     15                $t1 = self::factory()->term->create( array(
    1616                        'taxonomy' => 'wptests_tax',
    1717                        'name' => 'foo',
    1818                ) );
    19                 $t2 = self::$factory->term->create( array(
     19                $t2 = self::factory()->term->create( array(
    2020                        'taxonomy' => 'wptests_tax',
    2121                        'slug' => $t1,
    2222                ) );
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    2828        }
    2929
    3030        public function test_numeric_string_should_be_interpreted_as_term_slug() {
    31                 $t1 = self::$factory->term->create( array(
     31                $t1 = self::factory()->term->create( array(
    3232                        'taxonomy' => 'wptests_tax',
    3333                        'name' => 'foo',
    3434                ) );
    35                 $t2 = self::$factory->term->create( array(
     35                $t2 = self::factory()->term->create( array(
    3636                        'taxonomy' => 'wptests_tax',
    3737                        'slug' => $t1,
    3838                ) );
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    4949        }
    5050
    5151        public function test_category_should_use_cat_query_var_with_term_id() {
    52                 $c = self::$factory->category->create();
     52                $c = self::factory()->category->create();
    5353
    5454                $actual = get_term_link( $c, 'category' );
    5555                $this->assertContains( 'cat=' . $c, $actual );
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    6060                        'query_var' => 'foo',
    6161                ) );
    6262
    63                 $t = self::$factory->term->create( array(
     63                $t = self::factory()->term->create( array(
    6464                        'taxonomy' => 'wptests_tax2',
    6565                        'slug' => 'bar',
    6666                ) );
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    7474                        'query_var' => false,
    7575                ) );
    7676
    77                 $t = self::$factory->term->create( array(
     77                $t = self::factory()->term->create( array(
    7878                        'taxonomy' => 'wptests_tax2',
    7979                        'slug' => 'bar',
    8080                ) );
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    9797
    9898                flush_rewrite_rules();
    9999
    100                 $t1 = self::$factory->term->create( array(
     100                $t1 = self::factory()->term->create( array(
    101101                        'taxonomy' => 'wptests_tax2',
    102102                        'slug' => 'term1',
    103103                ) );
    104104
    105                 $t2 = self::$factory->term->create( array(
     105                $t2 = self::factory()->term->create( array(
    106106                        'taxonomy' => 'wptests_tax2',
    107107                        'slug' => 'term2',
    108108                        'parent' => $t1,
    class Tests_Term_GetTermLink extends WP_UnitTestCase { 
    126126
    127127                flush_rewrite_rules();
    128128
    129                 $t1 = self::$factory->term->create( array(
     129                $t1 = self::factory()->term->create( array(
    130130                        'taxonomy' => 'wptests_tax2',
    131131                        'slug' => 'term1',
    132132                ) );
    133133
    134                 $t2 = self::$factory->term->create( array(
     134                $t2 = self::factory()->term->create( array(
    135135                        'taxonomy' => 'wptests_tax2',
    136136                        'slug' => 'term2',
    137137                        'parent' => $t1,
  • tests/phpunit/tests/term/getTerms.php

    diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
    index bdc3146..f3e9316 100644
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    105105         * @ticket 23506
    106106         */
    107107        function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() {
    108                 $term_id = self::$factory->tag->create();
     108                $term_id = self::factory()->tag->create();
    109109                $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) );
    110110                $this->assertEquals( $term_id, reset( $terms )->term_id );
    111111        }
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    114114         * @ticket 13661
    115115         */
    116116        function test_get_terms_fields() {
    117                 $term_id1 = self::$factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
    118                 $term_id2 = self::$factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) );
     117                $term_id1 = self::factory()->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
     118                $term_id2 = self::factory()->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) );
    119119
    120120                $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
    121121                $this->assertEquals( array(
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    148148        function test_get_terms_include_exclude() {
    149149                global $wpdb;
    150150
    151                 $term_id1 = self::$factory->tag->create();
    152                 $term_id2 = self::$factory->tag->create();
     151                $term_id1 = self::factory()->tag->create();
     152                $term_id2 = self::factory()->tag->create();
    153153                $inc_terms = get_terms( 'post_tag', array(
    154154                        'include' => array( $term_id1, $term_id2 ),
    155155                        'hide_empty' => false
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    179179        public function test_exclude_with_hierarchical_true_for_non_hierarchical_taxonomy() {
    180180                register_taxonomy( 'wptests_tax', 'post' );
    181181
    182                 $terms = self::$factory->term->create_many( 2, array(
     182                $terms = self::factory()->term->create_many( 2, array(
    183183                        'taxonomy' => 'wptests_tax',
    184184                ) );
    185185
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    202202
    203203                $term_id_uncategorized = get_option( 'default_category' );
    204204
    205                 $term_id1 = self::$factory->category->create();
    206                 $term_id11 = self::$factory->category->create( array( 'parent' => $term_id1 ) );
    207                 $term_id2 = self::$factory->category->create();
    208                 $term_id22 = self::$factory->category->create( array( 'parent' => $term_id2 ) );
     205                $term_id1 = self::factory()->category->create();
     206                $term_id11 = self::factory()->category->create( array( 'parent' => $term_id1 ) );
     207                $term_id2 = self::factory()->category->create();
     208                $term_id22 = self::factory()->category->create( array( 'parent' => $term_id2 ) );
    209209
    210210                $terms = get_terms( 'category', array(
    211211                        'exclude' => $term_id_uncategorized,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    228228         * @ticket 13992
    229229         */
    230230        function test_get_terms_search() {
    231                 $term_id1 = self::$factory->tag->create( array( 'slug' => 'burrito' ) );
    232                 $term_id2 = self::$factory->tag->create( array( 'name' => 'Wilbur' ) );
     231                $term_id1 = self::factory()->tag->create( array( 'slug' => 'burrito' ) );
     232                $term_id2 = self::factory()->tag->create( array( 'name' => 'Wilbur' ) );
    233233
    234234                $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) );
    235235                $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    239239         * @ticket 8214
    240240         */
    241241        function test_get_terms_like() {
    242                 $term_id1 = self::$factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) );
    243                 $term_id2 = self::$factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) );
     242                $term_id1 = self::factory()->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) );
     243                $term_id2 = self::factory()->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) );
    244244
    245245                $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) );
    246246                $this->assertEqualSets( array( $term_id1 ), $terms );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    274274                $tax = 'food';
    275275                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    276276
    277                 $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
     277                $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
    278278
    279                 $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
     279                $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
    280280
    281                 $post_ids = self::$factory->post->create_many( 2 );
     281                $post_ids = self::factory()->post->create_many( 2 );
    282282                foreach ( $post_ids as $id ) {
    283283                        wp_set_post_terms( $id, $cheddar, $tax );
    284284                }
    285285                $term = get_term( $cheddar, $tax );
    286286                $this->assertEquals( 2, $term->count );
    287287
    288                 $brie = self::$factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );
    289                 $post_id = self::$factory->post->create();
     288                $brie = self::factory()->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );
     289                $post_id = self::factory()->post->create();
    290290                wp_set_post_terms( $post_id, $brie, $tax );
    291291                $term = get_term( $brie, $tax );
    292292                $this->assertEquals( 1, $term->count );
    293293
    294                 $crackers = self::$factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) );
     294                $crackers = self::factory()->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) );
    295295
    296                 $butter = self::$factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) );
    297                 $post_ids = self::$factory->post->create_many( 1 );
     296                $butter = self::factory()->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) );
     297                $post_ids = self::factory()->post->create_many( 1 );
    298298                foreach ( $post_ids as $id ) {
    299299                        wp_set_post_terms( $id, $butter, $tax );
    300300                }
    301301                $term = get_term( $butter, $tax );
    302302                $this->assertEquals( 1, $term->count );
    303303
    304                 $multigrain = self::$factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) );
    305                 $post_ids = self::$factory->post->create_many( 1 );
     304                $multigrain = self::factory()->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) );
     305                $post_ids = self::factory()->post->create_many( 1 );
    306306                foreach ( $post_ids as $id ) {
    307307                        wp_set_post_terms( $id, $multigrain, $tax );
    308308                }
    309309                $term = get_term( $multigrain, $tax );
    310310                $this->assertEquals( 1, $term->count );
    311311
    312                 $fruit = self::$factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );
    313                 $cranberries = self::$factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) );
     312                $fruit = self::factory()->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );
     313                $cranberries = self::factory()->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) );
    314314
    315315                $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
    316316                $this->assertEquals( 2, count( $terms ) );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    324324                $tax = 'food';
    325325                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    326326
    327                 $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
    328                 $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
    329                 $spread = self::$factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) );
    330                 $post_id = self::$factory->post->create();
     327                $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );
     328                $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );
     329                $spread = self::factory()->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) );
     330                $post_id = self::factory()->post->create();
    331331                wp_set_post_terms( $post_id, $spread, $tax );
    332332                $term = get_term( $spread, $tax );
    333333                $this->assertEquals( 1, $term->count );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    348348                $parent = 0;
    349349                $t = array();
    350350                foreach ( range( 1, 7 ) as $depth ) {
    351                         $t[$depth] = self::$factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) );
     351                        $t[$depth] = self::factory()->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) );
    352352                        $parent = $t[$depth];
    353353                }
    354                 $post_id = self::$factory->post->create();
     354                $post_id = self::factory()->post->create();
    355355                wp_set_post_terms( $post_id, $t[7], $tax );
    356356                $term = get_term( $t[7], $tax );
    357357                $this->assertEquals( 1, $term->count );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    367367         * @ticket 27123
    368368         */
    369369        function test_get_terms_child_of() {
    370                 $parent = self::$factory->category->create();
    371                 $child = self::$factory->category->create( array( 'parent' => $parent ) );
     370                $parent = self::factory()->category->create();
     371                $child = self::factory()->category->create( array( 'parent' => $parent ) );
    372372
    373373                $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) );
    374374                $this->assertEquals( 1, count( $terms ) );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    382382
    383383                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
    384384
    385                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     385                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    386386
    387387                $num_queries = $wpdb->num_queries;
    388388
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    402402                register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) );
    403403                register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    404404
    405                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    406                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    407                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
     405                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     406                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     407                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
    408408
    409409                $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    410410                        'fields' => 'ids',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    440440        public function test__get_term_children_handles_cycles() {
    441441                remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    442442
    443                 $c1 = self::$factory->category->create();
    444                 $c2 = self::$factory->category->create( array( 'parent' => $c1 ) );
    445                 $c3 = self::$factory->category->create( array( 'parent' => $c2 ) );
     443                $c1 = self::factory()->category->create();
     444                $c2 = self::factory()->category->create( array( 'parent' => $c1 ) );
     445                $c3 = self::factory()->category->create( array( 'parent' => $c2 ) );
    446446                wp_update_term( $c1, 'category', array( 'parent' => $c3 ) );
    447447
    448448                add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    459459        public function test__get_term_children_handles_cycles_when_terms_argument_contains_objects() {
    460460                remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    461461
    462                 $c1 = self::$factory->category->create_and_get();
    463                 $c2 = self::$factory->category->create_and_get( array( 'parent' => $c1->term_id ) );
    464                 $c3 = self::$factory->category->create_and_get( array( 'parent' => $c2->term_id ) );
     462                $c1 = self::factory()->category->create_and_get();
     463                $c2 = self::factory()->category->create_and_get( array( 'parent' => $c1->term_id ) );
     464                $c3 = self::factory()->category->create_and_get( array( 'parent' => $c2->term_id ) );
    465465                wp_update_term( $c1->term_id, 'category', array( 'parent' => $c3->term_id ) );
    466466
    467467                add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    472472        }
    473473
    474474        public function test_get_terms_by_slug() {
    475                 $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) );
    476                 $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) );
     475                $t1 = self::factory()->tag->create( array( 'slug' => 'foo' ) );
     476                $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) );
    477477
    478478                $found = get_terms( 'post_tag', array(
    479479                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    488488         * @ticket 23636
    489489         */
    490490        public function test_get_terms_by_multiple_slugs() {
    491                 $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) );
    492                 $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) );
    493                 $t3 = self::$factory->tag->create( array( 'slug' => 'barry' ) );
     491                $t1 = self::factory()->tag->create( array( 'slug' => 'foo' ) );
     492                $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) );
     493                $t3 = self::factory()->tag->create( array( 'slug' => 'barry' ) );
    494494
    495495                $found = get_terms( 'post_tag', array(
    496496                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    505505         * @ticket 30611
    506506         */
    507507        public function test_get_terms_by_name() {
    508                 $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) );
    509                 $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) );
     508                $t1 = self::factory()->tag->create( array( 'name' => 'Foo' ) );
     509                $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) );
    510510
    511511                $found = get_terms( 'post_tag', array(
    512512                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    521521         * @ticket 30611
    522522         */
    523523        public function test_get_terms_by_multiple_names() {
    524                 $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) );
    525                 $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) );
    526                 $t3 = self::$factory->tag->create( array( 'name' => 'Barry' ) );
     524                $t1 = self::factory()->tag->create( array( 'name' => 'Foo' ) );
     525                $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) );
     526                $t3 = self::factory()->tag->create( array( 'name' => 'Barry' ) );
    527527
    528528                $found = get_terms( 'post_tag', array(
    529529                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    540540        public function test_name_should_match_encoded_html_entities() {
    541541                register_taxonomy( 'wptests_tax', 'post' );
    542542
    543                 $t = self::$factory->term->create( array(
     543                $t = self::factory()->term->create( array(
    544544                        'taxonomy' => 'wptests_tax',
    545545                        'name' => 'Foo & Bar',
    546546                        'slug' => 'foo-and-bar',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    569569                // If run on a flat hierarchy it should return everything.
    570570                $flat_tax = 'countries';
    571571                register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) );
    572                 $australia = self::$factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) );
    573                 $china     = self::$factory->term->create( array( 'name' => 'China',     'taxonomy' => $flat_tax ) );
    574                 $tanzania  =  self::$factory->term->create( array( 'name' => 'Tanzania',  'taxonomy' => $flat_tax ) );
     572                $australia = self::factory()->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) );
     573                $china     = self::factory()->term->create( array( 'name' => 'China',     'taxonomy' => $flat_tax ) );
     574                $tanzania  =  self::factory()->term->create( array( 'name' => 'Tanzania',  'taxonomy' => $flat_tax ) );
    575575
    576576                $terms = get_terms( $flat_tax, array(
    577577                        'childless' => true,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    601601                        PEI
    602602                */
    603603                // Level 1
    604                 $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     604                $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
    605605
    606606                // Level 2
    607                 $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
    608                 $quebec  = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
    609                 $pei     = self::$factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) );
     607                $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
     608                $quebec  = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
     609                $pei     = self::factory()->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) );
    610610
    611611                // Level 3
    612                 $toronto  = self::$factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) );
    613                 $ottawa   = self::$factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) );
    614                 $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
     612                $toronto  = self::factory()->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) );
     613                $ottawa   = self::factory()->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) );
     614                $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
    615615
    616616                // Level 4
    617                 $nepean = self::$factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );
     617                $nepean = self::factory()->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );
    618618
    619619                $terms = get_terms( $tax, array(
    620620                        'childless' => true,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    633633                register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    634634
    635635                // Level 1
    636                 $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     636                $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
    637637
    638638                // Level 2
    639                 $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
    640                 $quebec  = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
     639                $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );
     640                $quebec  = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );
    641641
    642642                // Level 3
    643                 $laval   = self::$factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) );
    644                 $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
     643                $laval   = self::factory()->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) );
     644                $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );
    645645
    646646                // Level 4
    647                 $dorval = self::$factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );
     647                $dorval = self::factory()->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );
    648648
    649649                $terms = get_terms( $tax, array(
    650650                        'childless' => true,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    663663                register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) );
    664664                register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    665665
    666                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    667                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
    668                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    669                 $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) );
     666                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     667                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
     668                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     669                $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) );
    670670
    671671                $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    672672                        'fields' => 'ids',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    10981098                register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) );
    10991099                register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    11001100
    1101                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    1102                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
    1103                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) );
     1101                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     1102                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );
     1103                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) );
    11041104
    1105                 $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1106                 $t5 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) );
    1107                 $t6 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) );
     1105                $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     1106                $t5 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) );
     1107                $t6 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) );
    11081108
    1109                 $p = self::$factory->post->create();
     1109                $p = self::factory()->post->create();
    11101110
    11111111                wp_set_object_terms( $p, $t3, 'wptests_tax1' );
    11121112                wp_set_object_terms( $p, $t6, 'wptests_tax2' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    11401140                $tax = 'wptests_tax';
    11411141                register_taxonomy( $tax, 'post' );
    11421142
    1143                 $t1 = self::$factory->term->create( array( 'taxonomy' => $tax ) );
    1144                 $t2 = self::$factory->term->create( array( 'taxonomy' => $tax ) );
    1145                 $t3 = self::$factory->term->create( array( 'taxonomy' => $tax ) );
    1146                 $t4 = self::$factory->term->create( array( 'taxonomy' => $tax ) );
     1143                $t1 = self::factory()->term->create( array( 'taxonomy' => $tax ) );
     1144                $t2 = self::factory()->term->create( array( 'taxonomy' => $tax ) );
     1145                $t3 = self::factory()->term->create( array( 'taxonomy' => $tax ) );
     1146                $t4 = self::factory()->term->create( array( 'taxonomy' => $tax ) );
    11471147
    11481148                $found = get_terms( $tax, array(
    11491149                        'fields' => 'ids',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    11641164                $tax = 'wptests_tax';
    11651165                register_taxonomy( $tax, 'post' );
    11661166
    1167                 $t1 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) );
    1168                 $t2 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) );
    1169                 $t3 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) );
    1170                 $t4 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) );
     1167                $t1 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) );
     1168                $t2 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) );
     1169                $t3 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) );
     1170                $t4 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) );
    11711171
    11721172                $found = get_terms( $tax, array(
    11731173                        'fields' => 'ids',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    11851185         */
    11861186        public function test_orderby_term_id() {
    11871187                register_taxonomy( 'wptests_tax', 'post' );
    1188                 $t1 = self::$factory->term->create( array(
     1188                $t1 = self::factory()->term->create( array(
    11891189                        'taxonomy' => 'wptests_tax',
    11901190                        'name' => 'AAA',
    11911191                ) );
    1192                 $t2 = self::$factory->term->create( array(
     1192                $t2 = self::factory()->term->create( array(
    11931193                        'taxonomy' => 'wptests_tax',
    11941194                        'name' => 'ZZZ',
    11951195                ) );
    1196                 $t3 = self::$factory->term->create( array(
     1196                $t3 = self::factory()->term->create( array(
    11971197                        'taxonomy' => 'wptests_tax',
    11981198                        'name' => 'JJJ',
    11991199                ) );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    12431243
    12441244        public function test_hierarchical_false_with_child_of_and_direct_child() {
    12451245                $initial_terms = $this->create_hierarchical_terms();
    1246                 $post_id = self::$factory->post->create();
     1246                $post_id = self::factory()->post->create();
    12471247                wp_set_post_terms(
    12481248                        $post_id,
    12491249                        array( $initial_terms['seven_term']['term_id'] ),
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    13231323
    13241324                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
    13251325
    1326                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1326                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    13271327
    13281328                $num_queries = $wpdb->num_queries;
    13291329
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    13431343                register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) );
    13441344                register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    13451345
    1346                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    1347                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1348                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
     1346                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     1347                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     1348                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
    13491349
    13501350                $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
    13511351                        'fields' => 'ids',
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    13951395        public function test_pad_counts() {
    13961396                register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) );
    13971397
    1398                 $posts = self::$factory->post->create_many( 3 );
     1398                $posts = self::factory()->post->create_many( 3 );
    13991399
    1400                 $t1 = self::$factory->term->create( array(
     1400                $t1 = self::factory()->term->create( array(
    14011401                        'taxonomy' => 'wptests_tax_1',
    14021402                ) );
    1403                 $t2 = self::$factory->term->create( array(
     1403                $t2 = self::factory()->term->create( array(
    14041404                        'taxonomy' => 'wptests_tax_1',
    14051405                        'parent' => $t1,
    14061406                ) );
    1407                 $t3 = self::$factory->term->create( array(
     1407                $t3 = self::factory()->term->create( array(
    14081408                        'taxonomy' => 'wptests_tax_1',
    14091409                        'parent' => $t2,
    14101410                ) );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    14361436        public function test_pad_counts_should_not_recurse_infinitely_when_term_hierarchy_has_a_loop() {
    14371437                remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    14381438
    1439                 $c1 = self::$factory->category->create();
    1440                 $c2 = self::$factory->category->create( array( 'parent' => $c1 ) );
    1441                 $c3 = self::$factory->category->create( array( 'parent' => $c2 ) );
     1439                $c1 = self::factory()->category->create();
     1440                $c2 = self::factory()->category->create( array( 'parent' => $c1 ) );
     1441                $c3 = self::factory()->category->create( array( 'parent' => $c2 ) );
    14421442                wp_update_term( $c1, 'category', array( 'parent' => $c3 ) );
    14431443
    14441444                add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    14451445
    1446                 $posts = self::$factory->post->create_many( 3 );
     1446                $posts = self::factory()->post->create_many( 3 );
    14471447                wp_set_post_terms( $posts[0], $c1, 'category' );
    14481448                wp_set_post_terms( $posts[1], $c2, 'category' );
    14491449                wp_set_post_terms( $posts[2], $c3, 'category' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    14661466                register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => false ) );
    14671467                register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    14681468
    1469                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    1470                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1471                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
     1469                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     1470                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     1471                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );
    14721472
    1473                 $posts = self::$factory->post->create_many( 3 );
     1473                $posts = self::factory()->post->create_many( 3 );
    14741474                wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' );
    14751475                wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' );
    14761476                wp_set_object_terms( $posts[2], $t3, 'wptests_tax2' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    14991499                global $wpdb;
    15001500
    15011501                register_taxonomy( 'wptests_tax', 'post' );
    1502                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1502                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    15031503                add_term_meta( $terms[0], 'foo', 'bar' );
    15041504                add_term_meta( $terms[1], 'foo', 'bar' );
    15051505                add_term_meta( $terms[2], 'foo', 'bar' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    15251525                global $wpdb;
    15261526
    15271527                register_taxonomy( 'wptests_tax', 'post' );
    1528                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1528                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    15291529                add_term_meta( $terms[0], 'foo', 'bar' );
    15301530                add_term_meta( $terms[1], 'foo', 'bar' );
    15311531                add_term_meta( $terms[2], 'foo', 'bar' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    15501550         */
    15511551        public function test_meta_query() {
    15521552                register_taxonomy( 'wptests_tax', 'post' );
    1553                 $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
     1553                $terms = self::factory()->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
    15541554                add_term_meta( $terms[0], 'foo', 'bar' );
    15551555                add_term_meta( $terms[1], 'foo', 'bar' );
    15561556                add_term_meta( $terms[2], 'foo', 'baz' );
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    15751575         */
    15761576        public function test_should_return_wp_term_objects() {
    15771577                register_taxonomy( 'wptests_tax', 'post' );
    1578                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1578                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    15791579
    15801580                $found = get_terms( 'wptests_tax', array(
    15811581                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    15971597                global $wpdb;
    15981598
    15991599                register_taxonomy( 'wptests_tax', 'post' );
    1600                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1600                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    16011601
    16021602                // Prime the cache.
    16031603                get_terms( 'wptests_tax', array(
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    16281628                global $wpdb;
    16291629
    16301630                register_taxonomy( 'wptests_tax', 'post' );
    1631                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1631                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    16321632
    16331633                $found = get_terms( 'wptests_tax', array(
    16341634                        'hide_empty' => false,
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    16441644        protected function create_hierarchical_terms_and_posts() {
    16451645                $terms = array();
    16461646
    1647                 $terms['parent1'] = self::$factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) );
    1648                 $terms['parent2'] = self::$factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) );
    1649                 $terms['child1'] = self::$factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
    1650                 $terms['child2'] = self::$factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
    1651                 $terms['grandchild1'] = self::$factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) );
     1647                $terms['parent1'] = self::factory()->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) );
     1648                $terms['parent2'] = self::factory()->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) );
     1649                $terms['child1'] = self::factory()->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
     1650                $terms['child2'] = self::factory()->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );
     1651                $terms['grandchild1'] = self::factory()->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) );
    16521652
    1653                 $post_id = self::$factory->post->create();
     1653                $post_id = self::factory()->post->create();
    16541654                wp_set_post_terms( $post_id, $terms['parent2'], 'hierarchical_fields', true );
    16551655                wp_set_post_terms( $post_id, $terms['child1'], 'hierarchical_fields', true );
    16561656
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    17141714                );
    17151715
    17161716                // Ensure child terms are not empty
    1717                 $first_post_id = self::$factory->post->create();
    1718                 $second_post_id = self::$factory->post->create();
     1717                $first_post_id = self::factory()->post->create();
     1718                $second_post_id = self::factory()->post->create();
    17191719                wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' );
    17201720                wp_set_post_terms( $second_post_id, array( $six_term['term_id'] ), 'category' );
    17211721
    class Tests_Term_getTerms extends WP_UnitTestCase { 
    17311731        }
    17321732
    17331733        protected function set_up_three_posts_and_tags() {
    1734                 $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) );
     1734                $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) );
    17351735                foreach ( $posts as $post ) {
    17361736                        wp_set_object_terms( $post, rand_str(), 'post_tag' );
    17371737                }
  • tests/phpunit/tests/term/isObjectInTerm.php

    diff --git tests/phpunit/tests/term/isObjectInTerm.php tests/phpunit/tests/term/isObjectInTerm.php
    index 2e65a71..0da95ab 100644
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    77        public function test_terms_are_ints() {
    88                register_taxonomy( 'wptests_tax', 'post' );
    99
    10                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    11                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     10                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     11                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    1212
    13                 $posts = self::$factory->post->create_many( 2 );
     13                $posts = self::factory()->post->create_many( 2 );
    1414                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    1515
    1616                $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, $t2 ) ) );
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    2222        public function test_terms_are_strings_and_match_term_id() {
    2323                register_taxonomy( 'wptests_tax', 'post' );
    2424
    25                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    26                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     25                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     26                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    2727
    28                 $posts = self::$factory->post->create_many( 2 );
     28                $posts = self::factory()->post->create_many( 2 );
    2929                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    3030
    3131                $t1_str = (string) $t1;
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    4040        public function test_terms_are_strings_and_match_term_name() {
    4141                register_taxonomy( 'wptests_tax', 'post' );
    4242
    43                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) );
    44                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') );
     43                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) );
     44                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') );
    4545
    46                 $posts = self::$factory->post->create_many( 2 );
     46                $posts = self::factory()->post->create_many( 2 );
    4747                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    4848
    4949                $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'Foo', 'Bar' ) ) );
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    5555        public function test_terms_are_strings_and_match_term_slug() {
    5656                register_taxonomy( 'wptests_tax', 'post' );
    5757
    58                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
    59                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
     58                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
     59                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
    6060
    61                 $posts = self::$factory->post->create_many( 2 );
     61                $posts = self::factory()->post->create_many( 2 );
    6262                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    6363
    6464                $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'foo', 'bar' ) ) );
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    7070        public function test_terms_contain_strings_and_ints_and_match_term_id_as_int() {
    7171                register_taxonomy( 'wptests_tax', 'post' );
    7272
    73                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
    74                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
     73                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
     74                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
    7575
    76                 $posts = self::$factory->post->create_many( 2 );
     76                $posts = self::factory()->post->create_many( 2 );
    7777                wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    7878
    7979                $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, 'bar' ) ) );
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    8787         */
    8888        public function test_should_not_return_true_if_term_name_begins_with_existing_term_id() {
    8989                register_taxonomy( 'wptests_tax', 'post' );
    90                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     90                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    9191
    92                 $post_ID  = self::$factory->post->create();
     92                $post_ID  = self::factory()->post->create();
    9393                wp_set_object_terms( $post_ID, $t, 'wptests_tax' );
    9494
    9595                $int_tax_name = $t . '_term_name';
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    108108                global $wpdb;
    109109
    110110                register_taxonomy( 'wptests_tax', 'post' );
    111                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     111                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    112112
    113113                $o = 12345;
    114114                wp_set_object_terms( $o, $terms[0], 'wptests_tax' );
    class Tests_IsObjectInTerm extends WP_UnitTestCase { 
    129129                global $wpdb;
    130130
    131131                register_taxonomy( 'wptests_tax', 'post' );
    132                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     132                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    133133
    134134                $o = 12345;
    135135                wp_set_object_terms( $o, $terms[0], 'wptests_tax' );
  • tests/phpunit/tests/term/meta.php

    diff --git tests/phpunit/tests/term/meta.php tests/phpunit/tests/term/meta.php
    index dc96fcd..16e4527 100644
    class Tests_Term_Meta extends WP_UnitTestCase { 
    1212        }
    1313
    1414        public function test_add() {
    15                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     15                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    1616
    1717                $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) );
    1818        }
    1919
    2020        public function test_add_unique() {
    21                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     21                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    2222
    2323                $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) );
    2424                $this->assertFalse( add_term_meta( $t, 'foo', 'bar', true ) );
    2525        }
    2626
    2727        public function test_delete() {
    28                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     28                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    2929                add_term_meta( $t, 'foo', 'bar' );
    3030
    3131                $this->assertTrue( delete_term_meta( $t, 'foo' ) );
    3232        }
    3333
    3434        public function test_delete_with_invalid_meta_key_should_return_false() {
    35                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     35                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    3636
    3737                $this->assertFalse( delete_term_meta( $t, 'foo' ) );
    3838        }
    3939
    4040        public function test_delete_should_respect_meta_value() {
    41                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     41                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    4242                add_term_meta( $t, 'foo', 'bar' );
    4343                add_term_meta( $t, 'foo', 'baz' );
    4444
    class Tests_Term_Meta extends WP_UnitTestCase { 
    4949        }
    5050
    5151        public function test_get_with_no_key_should_fetch_all_keys() {
    52                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     52                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    5353                add_term_meta( $t, 'foo', 'bar' );
    5454                add_term_meta( $t, 'foo1', 'baz' );
    5555
    class Tests_Term_Meta extends WP_UnitTestCase { 
    6363        }
    6464
    6565        public function test_get_with_key_should_fetch_all_for_key() {
    66                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     66                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    6767                add_term_meta( $t, 'foo', 'bar' );
    6868                add_term_meta( $t, 'foo', 'baz' );
    6969                add_term_meta( $t, 'foo1', 'baz' );
    class Tests_Term_Meta extends WP_UnitTestCase { 
    7575        }
    7676
    7777        public function test_get_should_respect_single_true() {
    78                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     78                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    7979                add_term_meta( $t, 'foo', 'bar' );
    8080                add_term_meta( $t, 'foo', 'baz' );
    8181
    class Tests_Term_Meta extends WP_UnitTestCase { 
    8484        }
    8585
    8686        public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
    87                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     87                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    8888
    8989                $actual = update_term_meta( $t, 'foo', 'bar' );
    9090                $this->assertInternalType( 'int', $actual );
    class Tests_Term_Meta extends WP_UnitTestCase { 
    9595        }
    9696
    9797        public function test_update_should_return_true_when_updating_existing_value_for_key() {
    98                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     98                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    9999
    100100                add_term_meta( $t, 'foo', 'bar' );
    101101
    class Tests_Term_Meta extends WP_UnitTestCase { 
    109109        public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop() {
    110110                global $wpdb;
    111111
    112                 $p = self::$factory->post->create( array( 'post_status' => 'publish' ) );
     112                $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    113113
    114114                register_taxonomy( 'wptests_tax', 'post' );
    115                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     115                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    116116                wp_set_object_terms( $p, $terms, 'wptests_tax' );
    117117                foreach ( $terms as $t ) {
    118118                        add_term_meta( $t, 'foo', 'bar' );
    119119                }
    120120
    121121                // Create another term, which should *not* be lazy loaded because it's unattached.
    122                 $orphan_term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     122                $orphan_term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    123123                add_term_meta( $orphan_term, 'foo', 'bar' );
    124124
    125125                // Force results to be cached, even when using extended cache.
    class Tests_Term_Meta extends WP_UnitTestCase { 
    154154        public function test_term_meta_should_be_lazy_loaded_only_for_the_queries_in_which_the_term_has_posts() {
    155155                global $wpdb;
    156156
    157                 $posts = self::$factory->post->create_many( 3, array( 'post_status' => 'publish' ) );
     157                $posts = self::factory()->post->create_many( 3, array( 'post_status' => 'publish' ) );
    158158                register_taxonomy( 'wptests_tax', 'post' );
    159                 $terms = self::$factory->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) );
     159                $terms = self::factory()->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) );
    160160
    161161                wp_set_object_terms( $posts[0], array( $terms[0], $terms[1] ), 'wptests_tax' );
    162162                wp_set_object_terms( $posts[1], array( $terms[2], $terms[3] ), 'wptests_tax' );
    class Tests_Term_Meta extends WP_UnitTestCase { 
    201201        }
    202202
    203203        public function test_adding_term_meta_should_bust_get_terms_cache() {
    204                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     204                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    205205
    206206                add_term_meta( $terms[0], 'foo', 'bar' );
    207207
    class Tests_Term_Meta extends WP_UnitTestCase { 
    236236        }
    237237
    238238        public function test_updating_term_meta_should_bust_get_terms_cache() {
    239                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     239                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    240240
    241241                add_term_meta( $terms[0], 'foo', 'bar' );
    242242                add_term_meta( $terms[1], 'foo', 'baz' );
    class Tests_Term_Meta extends WP_UnitTestCase { 
    272272        }
    273273
    274274        public function test_deleting_term_meta_should_bust_get_terms_cache() {
    275                 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     275                $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    276276
    277277                add_term_meta( $terms[0], 'foo', 'bar' );
    278278                add_term_meta( $terms[1], 'foo', 'bar' );
  • tests/phpunit/tests/term/query.php

    diff --git tests/phpunit/tests/term/query.php tests/phpunit/tests/term/query.php
    index bc863b1..2b717c7 100644
    class Tests_Tax_Query extends WP_UnitTestCase { 
    125125        }
    126126
    127127        public function test_transform_query_resulting_field_sanitized() {
    128                 $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
    129                 $t2 = self::$factory->category->create( array( 'slug' => 'bar', ) );
    130                 $p = self::$factory->post->create();
     128                $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
     129                $t2 = self::factory()->category->create( array( 'slug' => 'bar', ) );
     130                $p = self::factory()->post->create();
    131131                wp_set_post_categories( $p, $t1 );
    132132
    133133                $tq1 = new WP_Tax_Query( array(
    class Tests_Tax_Query extends WP_UnitTestCase { 
    150150        }
    151151
    152152        public function test_transform_query_field_slug() {
    153                 $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
    154                 $p = self::$factory->post->create();
     153                $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
     154                $p = self::factory()->post->create();
    155155                $tt_ids = wp_set_post_categories( $p, $t1 );
    156156
    157157                $tq = new WP_Tax_Query( array(
    class Tests_Tax_Query extends WP_UnitTestCase { 
    168168        }
    169169
    170170        public function test_transform_query_field_name() {
    171                 $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    172                 $p = self::$factory->post->create();
     171                $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     172                $p = self::factory()->post->create();
    173173                $tt_ids = wp_set_post_categories( $p, $t1 );
    174174
    175175                $tq = new WP_Tax_Query( array(
    class Tests_Tax_Query extends WP_UnitTestCase { 
    186186        }
    187187
    188188        public function test_transform_query_field_term_taxonomy_id() {
    189                 $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    190                 $p = self::$factory->post->create();
     189                $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     190                $p = self::factory()->post->create();
    191191                $tt_ids = wp_set_post_categories( $p, $t1 );
    192192
    193193                $tq = new WP_Tax_Query( array(
    class Tests_Tax_Query extends WP_UnitTestCase { 
    204204        }
    205205
    206206        public function test_transform_query_field_term_taxonomy_default() {
    207                 $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
    208                 $p = self::$factory->post->create();
     207                $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
     208                $p = self::factory()->post->create();
    209209                $tt_ids = wp_set_post_categories( $p, $t1 );
    210210
    211211                $tq = new WP_Tax_Query( array(
    class Tests_Tax_Query extends WP_UnitTestCase { 
    240240        public function test_get_sql_relation_or_operator_in() {
    241241                register_taxonomy( 'wptests_tax', 'post' );
    242242
    243                 $t1 = self::$factory->term->create( array(
     243                $t1 = self::factory()->term->create( array(
    244244                        'taxonomy' => 'wptests_tax',
    245245                ) );
    246                 $t2 = self::$factory->term->create( array(
     246                $t2 = self::factory()->term->create( array(
    247247                        'taxonomy' => 'wptests_tax',
    248248                ) );
    249                 $t3 = self::$factory->term->create( array(
     249                $t3 = self::factory()->term->create( array(
    250250                        'taxonomy' => 'wptests_tax',
    251251                ) );
    252252
    class Tests_Tax_Query extends WP_UnitTestCase { 
    284284        public function test_get_sql_relation_and_operator_in() {
    285285                register_taxonomy( 'wptests_tax', 'post' );
    286286
    287                 $t1 = self::$factory->term->create( array(
     287                $t1 = self::factory()->term->create( array(
    288288                        'taxonomy' => 'wptests_tax',
    289289                ) );
    290                 $t2 = self::$factory->term->create( array(
     290                $t2 = self::factory()->term->create( array(
    291291                        'taxonomy' => 'wptests_tax',
    292292                ) );
    293                 $t3 = self::$factory->term->create( array(
     293                $t3 = self::factory()->term->create( array(
    294294                        'taxonomy' => 'wptests_tax',
    295295                ) );
    296296
    class Tests_Tax_Query extends WP_UnitTestCase { 
    327327        public function test_get_sql_nested_relation_or_operator_in() {
    328328                register_taxonomy( 'wptests_tax', 'post' );
    329329
    330                 $t1 = self::$factory->term->create( array(
     330                $t1 = self::factory()->term->create( array(
    331331                        'taxonomy' => 'wptests_tax',
    332332                ) );
    333                 $t2 = self::$factory->term->create( array(
     333                $t2 = self::factory()->term->create( array(
    334334                        'taxonomy' => 'wptests_tax',
    335335                ) );
    336                 $t3 = self::$factory->term->create( array(
     336                $t3 = self::factory()->term->create( array(
    337337                        'taxonomy' => 'wptests_tax',
    338338                ) );
    339339
  • tests/phpunit/tests/term/slashes.php

    diff --git tests/phpunit/tests/term/slashes.php tests/phpunit/tests/term/slashes.php
    index 7183bdb..9970a25 100644
     
    88class Tests_Term_Slashes extends WP_Ajax_UnitTestCase {
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     11                $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    1212                $this->old_current_user = get_current_user_id();
    1313                wp_set_current_user( $this->author_id );
    1414
    class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { 
    8484                        'post_tag'
    8585                );
    8686                foreach ( $taxonomies as $taxonomy ) {
    87                         $id = self::$factory->term->create(array(
     87                        $id = self::factory()->term->create(array(
    8888                                'taxonomy' => $taxonomy
    8989                        ));
    9090
  • tests/phpunit/tests/term/termExists.php

    diff --git tests/phpunit/tests/term/termExists.php tests/phpunit/tests/term/termExists.php
    index d628b31..b00b6e8 100644
    class Tests_TermExists extends WP_UnitTestCase { 
    99        }
    1010
    1111        public function test_term_exists_term_int_taxonomy_nonempty_term_exists() {
    12                 $t = self::$factory->term->create( array(
     12                $t = self::factory()->term->create( array(
    1313                        'taxonomy' => 'post_tag',
    1414                ) );
    1515
    class Tests_TermExists extends WP_UnitTestCase { 
    2222        }
    2323
    2424        public function test_term_exists_term_int_taxonomy_nonempty_wrong_taxonomy() {
    25                 $t = self::$factory->term->create( array(
     25                $t = self::factory()->term->create( array(
    2626                        'taxonomy' => 'post_tag',
    2727                ) );
    2828
    class Tests_TermExists extends WP_UnitTestCase { 
    3030        }
    3131
    3232        public function test_term_exists_term_int_taxonomy_empty_term_exists() {
    33                 $t = self::$factory->term->create( array(
     33                $t = self::factory()->term->create( array(
    3434                        'taxonomy' => 'post_tag',
    3535                ) );
    3636
    class Tests_TermExists extends WP_UnitTestCase { 
    4343        }
    4444
    4545        public function test_term_exists_unslash_term() {
    46                 $t = self::$factory->term->create( array(
     46                $t = self::factory()->term->create( array(
    4747                        'taxonomy' => 'post_tag',
    4848                        'name' => 'I "love" WordPress\'s taxonomy system',
    4949                ) );
    class Tests_TermExists extends WP_UnitTestCase { 
    5353        }
    5454
    5555        public function test_term_exists_trim_term() {
    56                 $t = self::$factory->term->create( array(
     56                $t = self::factory()->term->create( array(
    5757                        'taxonomy' => 'post_tag',
    5858                        'slug' => 'foo',
    5959                ) );
    class Tests_TermExists extends WP_UnitTestCase { 
    8484                        'hierarchical' => true,
    8585                ) );
    8686
    87                 $parent_term = self::$factory->term->create( array(
     87                $parent_term = self::factory()->term->create( array(
    8888                        'taxonomy' => 'foo',
    8989                ) );
    9090
    91                 $t = self::$factory->term->create( array(
     91                $t = self::factory()->term->create( array(
    9292                        'taxonomy' => 'foo',
    9393                        'parent' => $parent_term,
    9494                        'slug' => 'child-term',
    class Tests_TermExists extends WP_UnitTestCase { 
    110110                        'hierarchical' => true,
    111111                ) );
    112112
    113                 $parent_term = self::$factory->term->create( array(
     113                $parent_term = self::factory()->term->create( array(
    114114                        'taxonomy' => 'foo',
    115115                ) );
    116116
    117                 $t = self::$factory->term->create( array(
     117                $t = self::factory()->term->create( array(
    118118                        'taxonomy' => 'foo',
    119119                        'parent' => $parent_term,
    120120                        'slug' => 'child-term',
    class Tests_TermExists extends WP_UnitTestCase { 
    132132                        'hierarchical' => true,
    133133                ) );
    134134
    135                 $parent_term = self::$factory->term->create( array(
     135                $parent_term = self::factory()->term->create( array(
    136136                        'taxonomy' => 'foo',
    137137                ) );
    138138
    139                 $t = self::$factory->term->create( array(
     139                $t = self::factory()->term->create( array(
    140140                        'taxonomy' => 'foo',
    141141                        'parent' => $parent_term,
    142142                        'name' => 'Child Term',
    class Tests_TermExists extends WP_UnitTestCase { 
    153153        public function test_term_exists_taxonomy_nonempty_parent_empty_match_slug() {
    154154                register_taxonomy( 'foo', 'post', array() );
    155155
    156                 $t = self::$factory->term->create( array(
     156                $t = self::factory()->term->create( array(
    157157                        'taxonomy' => 'foo',
    158158                        'slug' => 'kewl-dudez',
    159159                ) );
    class Tests_TermExists extends WP_UnitTestCase { 
    169169        public function test_term_exists_taxonomy_nonempty_parent_empty_match_name() {
    170170                register_taxonomy( 'foo', 'post', array() );
    171171
    172                 $t = self::$factory->term->create( array(
     172                $t = self::factory()->term->create( array(
    173173                        'taxonomy' => 'foo',
    174174                        'name' => 'Kewl Dudez',
    175175                ) );
    class Tests_TermExists extends WP_UnitTestCase { 
    185185        public function test_term_exists_taxonomy_empty_parent_empty_match_slug() {
    186186                register_taxonomy( 'foo', 'post', array() );
    187187
    188                 $t = self::$factory->term->create( array(
     188                $t = self::factory()->term->create( array(
    189189                        'taxonomy' => 'foo',
    190190                        'name' => 'juicy-fruit',
    191191                ) );
    class Tests_TermExists extends WP_UnitTestCase { 
    201201        public function test_term_exists_taxonomy_empty_parent_empty_match_name() {
    202202                register_taxonomy( 'foo', 'post', array() );
    203203
    204                 $t = self::$factory->term->create( array(
     204                $t = self::factory()->term->create( array(
    205205                        'taxonomy' => 'foo',
    206206                        'name' => 'Juicy Fruit',
    207207                ) );
  • tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php

    diff --git tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php
    index dee5918..319a818 100644
    class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { 
    99                register_taxonomy( 'wptests_tax1', 'post' );
    1010                register_taxonomy( 'wptests_tax2', 'post' );
    1111
    12                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    13                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     12                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     13                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    1414
    1515                $object_id = 567;
    1616
    class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { 
    3333                register_taxonomy( 'wptests_tax2', 'post' );
    3434                register_taxonomy( 'wptests_tax3', 'post' );
    3535
    36                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    37                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    38                 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax3' ) );
     36                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     37                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     38                $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax3' ) );
    3939
    4040                $object_id = 567;
    4141
  • tests/phpunit/tests/term/wpDeleteTerm.php

    diff --git tests/phpunit/tests/term/wpDeleteTerm.php tests/phpunit/tests/term/wpDeleteTerm.php
    index f47caa4..7a62d72 100644
    class Tests_Term_WpDeleteTerm extends WP_UnitTestCase { 
    1212        public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() {
    1313                register_taxonomy( 'wptests_tax', 'post' );
    1414
    15                 $terms = self::$factory->term->create_many( 2, array(
     15                $terms = self::factory()->term->create_many( 2, array(
    1616                        'taxonomy' => 'wptests_tax',
    1717                ) );
    1818
    19                 $p = self::$factory->post->create();
     19                $p = self::factory()->post->create();
    2020
    2121                wp_set_object_terms( $p, array( $terms[0] ), 'wptests_tax' );
    2222
  • tests/phpunit/tests/term/wpGenerateTagCloud.php

    diff --git tests/phpunit/tests/term/wpGenerateTagCloud.php tests/phpunit/tests/term/wpGenerateTagCloud.php
    index 7f5352d..742b321 100644
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    2727         * @param $args     Options for `wp_generate_tag_cloud()`.
    2828         */
    2929        function test_empty_tags_list_returned( $expected, $args ) {
    30                 $term_ids = self::$factory->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) );
     30                $term_ids = self::factory()->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) );
    3131                $this->terms = array();
    3232                foreach ( $term_ids as $term_id ) {
    3333                        $this->terms[] = get_term( $term_id, 'post_tag' );
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    7171        }
    7272
    7373        function test_hide_empty_false() {
    74                 $term_id = self::$factory->tag->create();
     74                $term_id = self::factory()->tag->create();
    7575                $term = get_term( $term_id, 'post_tag' );
    7676
    7777                $tags = $this->retrieve_terms( array(
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    8585        }
    8686
    8787        function test_hide_empty_false_format_array() {
    88                 $term_id = self::$factory->tag->create();
     88                $term_id = self::factory()->tag->create();
    8989                $term = get_term( $term_id, 'post_tag' );
    9090
    9191                $tags = $this->retrieve_terms( array(
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    101101        }
    102102
    103103        function test_hide_empty_false_format_list() {
    104                 $term_id = self::$factory->tag->create();
     104                $term_id = self::factory()->tag->create();
    105105                $term = get_term( $term_id, 'post_tag' );
    106106
    107107                $tags = $this->retrieve_terms( array(
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    117117        }
    118118
    119119        function test_hide_empty_false_multi() {
    120                 $term_ids = self::$factory->tag->create_many( 4 );
     120                $term_ids = self::factory()->tag->create_many( 4 );
    121121                $terms = array();
    122122                foreach ( $term_ids as $term_id ) {
    123123                        $terms[] = get_term( $term_id, 'post_tag' );
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    139139        }
    140140
    141141        function test_hide_empty_false_multi_format_list() {
    142                 $term_ids = self::$factory->tag->create_many( 4 );
     142                $term_ids = self::factory()->tag->create_many( 4 );
    143143                $terms = array();
    144144                foreach ( $term_ids as $term_id ) {
    145145                        $terms[] = get_term( $term_id, 'post_tag' );
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    166166
    167167        public function test_topic_count_text() {
    168168                register_taxonomy( 'wptests_tax', 'post' );
    169                 $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     169                $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    170170                $this->terms = array();
    171171                foreach ( $term_ids as $term_id ) {
    172172                        $this->terms[] = get_term( $term_id, 'post_tag' );
    173173                }
    174                 $posts = self::$factory->post->create_many( 2 );
     174                $posts = self::factory()->post->create_many( 2 );
    175175
    176176                wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' );
    177177                wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' );
    class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { 
    196196
    197197        public function test_topic_count_text_callback() {
    198198                register_taxonomy( 'wptests_tax', 'post' );
    199                 $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     199                $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    200200                $this->terms = array();
    201201                foreach ( $term_ids as $term_id ) {
    202202                        $this->terms[] = get_term( $term_id, 'post_tag' );
    203203                }
    204                 $posts = self::$factory->post->create_many( 2 );
     204                $posts = self::factory()->post->create_many( 2 );
    205205
    206206                wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' );
    207207                wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' );
  • tests/phpunit/tests/term/wpGetObjectTerms.php

    diff --git tests/phpunit/tests/term/wpGetObjectTerms.php tests/phpunit/tests/term/wpGetObjectTerms.php
    index 3d7a90f..ffa8781 100644
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    1313        }
    1414
    1515        public function test_get_object_terms_by_slug() {
    16                 $post_id = self::$factory->post->create();
     16                $post_id = self::factory()->post->create();
    1717
    1818                $terms_1 = array('Foo', 'Bar', 'Baz');
    1919                $terms_1_slugs = array('foo', 'bar', 'baz');
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    3131         * @ticket 11003
    3232         */
    3333        public function test_should_not_filter_out_duplicate_terms_associated_with_different_objects() {
    34                 $post_id1 = self::$factory->post->create();
    35                 $post_id2 = self::$factory->post->create();
    36                 $cat_id = self::$factory->category->create();
    37                 $cat_id2 = self::$factory->category->create();
     34                $post_id1 = self::factory()->post->create();
     35                $post_id2 = self::factory()->post->create();
     36                $cat_id = self::factory()->category->create();
     37                $cat_id2 = self::factory()->category->create();
    3838                wp_set_post_categories( $post_id1, array( $cat_id, $cat_id2 ) );
    3939                wp_set_post_categories( $post_id2, $cat_id );
    4040
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    5454         * @ticket 17646
    5555         */
    5656        public function test_should_return_objects_with_int_properties() {
    57                 $post_id = self::$factory->post->create();
     57                $post_id = self::factory()->post->create();
    5858                $term = wp_insert_term( 'one', $this->taxonomy );
    5959                wp_set_object_terms( $post_id, $term, $this->taxonomy );
    6060
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    7373         * @ticket 26339
    7474         */
    7575        public function test_references_should_be_reset_after_wp_get_object_terms_filter() {
    76                 $post_id = self::$factory->post->create();
     76                $post_id = self::factory()->post->create();
    7777                $terms_1 = array('foo', 'bar', 'baz');
    7878
    7979                wp_set_object_terms( $post_id, $terms_1, $this->taxonomy );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    8686        }
    8787
    8888        public function test_orderby_name() {
    89                 $p = self::$factory->post->create();
     89                $p = self::factory()->post->create();
    9090
    91                 $t1 = self::$factory->term->create( array(
     91                $t1 = self::factory()->term->create( array(
    9292                        'taxonomy' => $this->taxonomy,
    9393                        'name' => 'AAA',
    9494                ) );
    95                 $t2 = self::$factory->term->create( array(
     95                $t2 = self::factory()->term->create( array(
    9696                        'taxonomy' => $this->taxonomy,
    9797                        'name' => 'ZZZ',
    9898                ) );
    99                 $t3 = self::$factory->term->create( array(
     99                $t3 = self::factory()->term->create( array(
    100100                        'taxonomy' => $this->taxonomy,
    101101                        'name' => 'JJJ',
    102102                ) );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    112112        }
    113113
    114114        public function test_orderby_count() {
    115                 $posts = self::$factory->post->create_many( 3 );
     115                $posts = self::factory()->post->create_many( 3 );
    116116
    117                 $t1 = self::$factory->term->create( array(
     117                $t1 = self::factory()->term->create( array(
    118118                        'taxonomy' => $this->taxonomy,
    119119                        'name' => 'AAA',
    120120                ) );
    121                 $t2 = self::$factory->term->create( array(
     121                $t2 = self::factory()->term->create( array(
    122122                        'taxonomy' => $this->taxonomy,
    123123                        'name' => 'ZZZ',
    124124                ) );
    125                 $t3 = self::$factory->term->create( array(
     125                $t3 = self::factory()->term->create( array(
    126126                        'taxonomy' => $this->taxonomy,
    127127                        'name' => 'JJJ',
    128128                ) );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    140140        }
    141141
    142142        public function test_orderby_slug() {
    143                 $p = self::$factory->post->create();
     143                $p = self::factory()->post->create();
    144144
    145                 $t1 = self::$factory->term->create( array(
     145                $t1 = self::factory()->term->create( array(
    146146                        'taxonomy' => $this->taxonomy,
    147147                        'slug' => 'aaa',
    148148                ) );
    149                 $t2 = self::$factory->term->create( array(
     149                $t2 = self::factory()->term->create( array(
    150150                        'taxonomy' => $this->taxonomy,
    151151                        'slug' => 'zzz',
    152152                ) );
    153                 $t3 = self::$factory->term->create( array(
     153                $t3 = self::factory()->term->create( array(
    154154                        'taxonomy' => $this->taxonomy,
    155155                        'slug' => 'jjj',
    156156                ) );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    166166        }
    167167
    168168        public function test_orderby_term_group() {
    169                 $p = self::$factory->post->create();
     169                $p = self::factory()->post->create();
    170170
    171                 $t1 = self::$factory->term->create( array(
     171                $t1 = self::factory()->term->create( array(
    172172                        'taxonomy' => $this->taxonomy,
    173173                ) );
    174                 $t2 = self::$factory->term->create( array(
     174                $t2 = self::factory()->term->create( array(
    175175                        'taxonomy' => $this->taxonomy,
    176176                ) );
    177                 $t3 = self::$factory->term->create( array(
     177                $t3 = self::factory()->term->create( array(
    178178                        'taxonomy' => $this->taxonomy,
    179179                ) );
    180180
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    195195        }
    196196
    197197        public function test_orderby_term_order() {
    198                 $p = self::$factory->post->create();
     198                $p = self::factory()->post->create();
    199199
    200                 $t1 = self::$factory->term->create( array(
     200                $t1 = self::factory()->term->create( array(
    201201                        'taxonomy' => $this->taxonomy,
    202202                ) );
    203                 $t2 = self::$factory->term->create( array(
     203                $t2 = self::factory()->term->create( array(
    204204                        'taxonomy' => $this->taxonomy,
    205205                ) );
    206                 $t3 = self::$factory->term->create( array(
     206                $t3 = self::factory()->term->create( array(
    207207                        'taxonomy' => $this->taxonomy,
    208208                ) );
    209209
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    231231         * @ticket 28688
    232232         */
    233233        public function test_orderby_parent() {
    234                 $p = self::$factory->post->create();
     234                $p = self::factory()->post->create();
    235235
    236                 $t1 = self::$factory->term->create( array(
     236                $t1 = self::factory()->term->create( array(
    237237                        'taxonomy' => $this->taxonomy,
    238238                ) );
    239                 $t2 = self::$factory->term->create( array(
     239                $t2 = self::factory()->term->create( array(
    240240                        'taxonomy' => $this->taxonomy,
    241241                ) );
    242                 $t3 = self::$factory->term->create( array(
     242                $t3 = self::factory()->term->create( array(
    243243                        'taxonomy' => $this->taxonomy,
    244244                ) );
    245245
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    269269                register_taxonomy( 'wptests_tax_2', 'post' );
    270270                register_taxonomy( 'wptests_tax_3', 'post' );
    271271
    272                 $p = self::$factory->post->create();
     272                $p = self::factory()->post->create();
    273273
    274                 $t1 = self::$factory->term->create( array(
     274                $t1 = self::factory()->term->create( array(
    275275                        'taxonomy' => $this->taxonomy,
    276276                ) );
    277                 $t2 = self::$factory->term->create( array(
     277                $t2 = self::factory()->term->create( array(
    278278                        'taxonomy' => 'wptests_tax_3',
    279279                ) );
    280                 $t3 = self::$factory->term->create( array(
     280                $t3 = self::factory()->term->create( array(
    281281                        'taxonomy' => 'wptests_tax_2',
    282282                ) );
    283283
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    297297         * @ticket 28688
    298298         */
    299299        public function test_orderby_tt_id() {
    300                 $p = self::$factory->post->create();
     300                $p = self::factory()->post->create();
    301301
    302                 $t1 = self::$factory->term->create( array(
     302                $t1 = self::factory()->term->create( array(
    303303                        'taxonomy' => $this->taxonomy,
    304304                ) );
    305                 $t2 = self::$factory->term->create( array(
     305                $t2 = self::factory()->term->create( array(
    306306                        'taxonomy' => $this->taxonomy,
    307307                ) );
    308                 $t3 = self::$factory->term->create( array(
     308                $t3 = self::factory()->term->create( array(
    309309                        'taxonomy' => $this->taxonomy,
    310310                ) );
    311311
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    330330        }
    331331
    332332        public function test_order_desc() {
    333                 $p = self::$factory->post->create();
     333                $p = self::factory()->post->create();
    334334
    335                 $t1 = self::$factory->term->create( array(
     335                $t1 = self::factory()->term->create( array(
    336336                        'taxonomy' => $this->taxonomy,
    337337                        'name' => 'AAA',
    338338                ) );
    339                 $t2 = self::$factory->term->create( array(
     339                $t2 = self::factory()->term->create( array(
    340340                        'taxonomy' => $this->taxonomy,
    341341                        'name' => 'ZZZ',
    342342                ) );
    343                 $t3 = self::$factory->term->create( array(
     343                $t3 = self::factory()->term->create( array(
    344344                        'taxonomy' => $this->taxonomy,
    345345                        'name' => 'JJJ',
    346346                ) );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    360360         * @ticket 15675
    361361         */
    362362        public function test_parent() {
    363                 $t1 = self::$factory->term->create( array(
     363                $t1 = self::factory()->term->create( array(
    364364                        'taxonomy' => $this->taxonomy,
    365365                ) );
    366                 $t2 = self::$factory->term->create( array(
     366                $t2 = self::factory()->term->create( array(
    367367                        'taxonomy' => $this->taxonomy,
    368368                ) );
    369                 $t3 = self::$factory->term->create( array(
     369                $t3 = self::factory()->term->create( array(
    370370                        'taxonomy' => $this->taxonomy,
    371371                        'parent' => $t1,
    372372                ) );
    373                 $t4 = self::$factory->term->create( array(
     373                $t4 = self::factory()->term->create( array(
    374374                        'taxonomy' => $this->taxonomy,
    375375                        'parent' => $t2,
    376376                ) );
    377377
    378                 $p = self::$factory->post->create();
     378                $p = self::factory()->post->create();
    379379
    380380                wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy );
    381381
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    391391         * @ticket 15675
    392392         */
    393393        public function test_parent_0() {
    394                 $t1 = self::$factory->term->create( array(
     394                $t1 = self::factory()->term->create( array(
    395395                        'taxonomy' => $this->taxonomy,
    396396                ) );
    397                 $t2 = self::$factory->term->create( array(
     397                $t2 = self::factory()->term->create( array(
    398398                        'taxonomy' => $this->taxonomy,
    399399                ) );
    400                 $t3 = self::$factory->term->create( array(
     400                $t3 = self::factory()->term->create( array(
    401401                        'taxonomy' => $this->taxonomy,
    402402                        'parent' => $t1,
    403403                ) );
    404                 $t4 = self::$factory->term->create( array(
     404                $t4 = self::factory()->term->create( array(
    405405                        'taxonomy' => $this->taxonomy,
    406406                        'parent' => $t2,
    407407                ) );
    408408
    409                 $p = self::$factory->post->create();
     409                $p = self::factory()->post->create();
    410410
    411411                wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy );
    412412
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    425425                global $wpdb;
    426426
    427427                register_taxonomy( 'wptests_tax', 'post' );
    428                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     428                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    429429                add_term_meta( $terms[0], 'foo', 'bar' );
    430430                add_term_meta( $terms[1], 'foo', 'bar' );
    431431                add_term_meta( $terms[2], 'foo', 'bar' );
    432432
    433                 $p = self::$factory->post->create();
     433                $p = self::factory()->post->create();
    434434                wp_set_object_terms( $p, $terms, 'wptests_tax' );
    435435
    436436                $found = wp_get_object_terms( $p, 'wptests_tax' );
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    451451                global $wpdb;
    452452
    453453                register_taxonomy( 'wptests_tax', 'post' );
    454                 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     454                $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    455455                add_term_meta( $terms[0], 'foo', 'bar' );
    456456                add_term_meta( $terms[1], 'foo', 'bar' );
    457457                add_term_meta( $terms[2], 'foo', 'bar' );
    458458
    459                 $p = self::$factory->post->create();
     459                $p = self::factory()->post->create();
    460460                wp_set_object_terms( $p, $terms, 'wptests_tax' );
    461461
    462462                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    477477         */
    478478        public function test_meta_query() {
    479479                register_taxonomy( 'wptests_tax', 'post' );
    480                 $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
     480                $terms = self::factory()->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
    481481                add_term_meta( $terms[0], 'foo', 'bar' );
    482482                add_term_meta( $terms[1], 'foo', 'bar' );
    483483                add_term_meta( $terms[2], 'foo', 'baz' );
    484484                add_term_meta( $terms[3], 'foob', 'ar' );
    485485
    486                 $p = self::$factory->post->create();
     486                $p = self::factory()->post->create();
    487487                wp_set_object_terms( $p, $terms, 'wptests_tax' );
    488488
    489489                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    503503         */
    504504        public function test_should_return_wp_term_objects_for_fields_all() {
    505505                register_taxonomy( 'wptests_tax', 'post' );
    506                 $p = self::$factory->post->create();
    507                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     506                $p = self::factory()->post->create();
     507                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    508508                wp_set_object_terms( $p, $t, 'wptests_tax' );
    509509
    510510                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    522522         */
    523523        public function test_should_return_wp_term_objects_for_fields_all_with_object_id() {
    524524                register_taxonomy( 'wptests_tax', 'post' );
    525                 $p = self::$factory->post->create();
    526                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     525                $p = self::factory()->post->create();
     526                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    527527                wp_set_object_terms( $p, $t, 'wptests_tax' );
    528528
    529529                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    543543                global $wpdb;
    544544
    545545                register_taxonomy( 'wptests_tax', 'post' );
    546                 $p = self::$factory->post->create();
    547                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     546                $p = self::factory()->post->create();
     547                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    548548                wp_set_object_terms( $p, $t, 'wptests_tax' );
    549549
    550550                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    561561         */
    562562        public function test_object_id_should_not_be_cached_with_term_object() {
    563563                register_taxonomy( 'wptests_tax', 'post' );
    564                 $p = self::$factory->post->create();
    565                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     564                $p = self::factory()->post->create();
     565                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    566566                wp_set_object_terms( $p, $t, 'wptests_tax' );
    567567
    568568                $found = wp_get_object_terms( $p, 'wptests_tax', array(
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    585585
    586586                register_taxonomy( 'wptests_tax1', 'post' );
    587587                register_taxonomy( 'wptests_tax2', 'post' );
    588                 $p = self::$factory->post->create();
    589                 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
    590                 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
     588                $p = self::factory()->post->create();
     589                $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
     590                $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
    591591                wp_set_object_terms( $p, $t1, 'wptests_tax1' );
    592592                wp_set_object_terms( $p, $t2, 'wptests_tax2' );
    593593
    class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 
    611611         */
    612612        public function test_object_id_should_be_set_on_objects_that_share_terms() {
    613613                register_taxonomy( 'wptests_tax', 'post' );
    614                 $posts = self::$factory->post->create_many( 2 );
    615                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     614                $posts = self::factory()->post->create_many( 2 );
     615                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    616616                wp_set_object_terms( $posts[0], $t, 'wptests_tax' );
    617617                wp_set_object_terms( $posts[1], $t, 'wptests_tax' );
    618618
  • tests/phpunit/tests/term/wpInsertTerm.php

    diff --git tests/phpunit/tests/term/wpInsertTerm.php tests/phpunit/tests/term/wpInsertTerm.php
    index 18e3fd3..ea7ba45 100644
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    160160         * @ticket 17689
    161161         */
    162162        public function test_wp_insert_term_duplicate_name() {
    163                 $term = self::$factory->tag->create_and_get( array( 'name' => 'Bozo' ) );
     163                $term = self::factory()->tag->create_and_get( array( 'name' => 'Bozo' ) );
    164164                $this->assertNotWPError( $term );
    165165                $this->assertTrue( empty( $term->errors ) );
    166166
    167167                // Test existing term name with unique slug
    168                 $term1 = self::$factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );
     168                $term1 = self::factory()->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );
    169169                $this->assertNotWPError( $term1 );
    170170
    171171                // Test an existing term name
    172                 $term2 = self::$factory->tag->create( array( 'name' => 'Bozo' ) );
     172                $term2 = self::factory()->tag->create( array( 'name' => 'Bozo' ) );
    173173                $this->assertTrue( is_wp_error( $term2 ) );
    174174                $this->assertNotEmpty( $term2->errors );
    175175
    176176                // Test named terms ending in special characters
    177                 $term3 = self::$factory->tag->create( array( 'name' => 'T$' ) );
    178                 $term4 = self::$factory->tag->create( array( 'name' => 'T$$' ) );
    179                 $term5 = self::$factory->tag->create( array( 'name' => 'T$$$' ) );
    180                 $term6 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) );
    181                 $term7 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) );
     177                $term3 = self::factory()->tag->create( array( 'name' => 'T$' ) );
     178                $term4 = self::factory()->tag->create( array( 'name' => 'T$$' ) );
     179                $term5 = self::factory()->tag->create( array( 'name' => 'T$$$' ) );
     180                $term6 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) );
     181                $term7 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) );
    182182                $this->assertTrue( is_wp_error( $term7 ) );
    183183                $this->assertNotEmpty( $term7->errors );
    184184                $this->assertEquals( $term6, $term7->error_data['term_exists'] );
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    187187                $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );
    188188
    189189                // Test named terms with only special characters
    190                 $term8 = self::$factory->tag->create( array( 'name' => '$' ) );
    191                 $term9 = self::$factory->tag->create( array( 'name' => '$$' ) );
    192                 $term10 = self::$factory->tag->create( array( 'name' => '$$$' ) );
    193                 $term11 = self::$factory->tag->create( array( 'name' => '$$$$' ) );
    194                 $term12 = self::$factory->tag->create( array( 'name' => '$$$$' ) );
     190                $term8 = self::factory()->tag->create( array( 'name' => '$' ) );
     191                $term9 = self::factory()->tag->create( array( 'name' => '$$' ) );
     192                $term10 = self::factory()->tag->create( array( 'name' => '$$$' ) );
     193                $term11 = self::factory()->tag->create( array( 'name' => '$$$$' ) );
     194                $term12 = self::factory()->tag->create( array( 'name' => '$$$$' ) );
    195195                $this->assertTrue( is_wp_error( $term12 ) );
    196196                $this->assertNotEmpty( $term12->errors );
    197197                $this->assertEquals( $term11, $term12->error_data['term_exists'] );
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    199199                $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) );
    200200                $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) );
    201201
    202                 $term13 = self::$factory->tag->create( array( 'name' => 'A' ) );
     202                $term13 = self::factory()->tag->create( array( 'name' => 'A' ) );
    203203                $this->assertNotWPError( $term13 );
    204                 $term14 = self::$factory->tag->create( array( 'name' => 'A' ) );
     204                $term14 = self::factory()->tag->create( array( 'name' => 'A' ) );
    205205                $this->assertTrue( is_wp_error( $term14 ) );
    206                 $term15 = self::$factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) );
     206                $term15 = self::factory()->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) );
    207207                $this->assertNotWPError( $term15 );
    208                 $term16 = self::$factory->tag->create( array( 'name' => 'A+' ) );
     208                $term16 = self::factory()->tag->create( array( 'name' => 'A+' ) );
    209209                $this->assertTrue( is_wp_error( $term16 ) );
    210                 $term17 = self::$factory->tag->create( array( 'name' => 'A++' ) );
     210                $term17 = self::factory()->tag->create( array( 'name' => 'A++' ) );
    211211                $this->assertNotWPError( $term17 );
    212                 $term18 = self::$factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) );
     212                $term18 = self::factory()->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) );
    213213                $this->assertNotWPError( $term18 );
    214                 $term19 = self::$factory->tag->create( array( 'name' => 'A-' ) );
     214                $term19 = self::factory()->tag->create( array( 'name' => 'A-' ) );
    215215                $this->assertTrue( is_wp_error( $term19 ) );
    216                 $term20 = self::$factory->tag->create( array( 'name' => 'A--' ) );
     216                $term20 = self::factory()->tag->create( array( 'name' => 'A--' ) );
    217217                $this->assertNotWPError( $term20 );
    218218        }
    219219
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    222222         */
    223223        public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_non_hierarchical_taxonomy() {
    224224                register_taxonomy( 'wptests_tax', 'post' );
    225                 $t1 = self::$factory->term->create( array(
     225                $t1 = self::factory()->term->create( array(
    226226                        'name' => 'Foo',
    227227                        'slug' => 'foo',
    228228                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    241241         */
    242242        public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_in_non_hierarchical_taxonomy() {
    243243                register_taxonomy( 'wptests_tax', 'post' );
    244                 $t1 = self::$factory->term->create( array(
     244                $t1 = self::factory()->term->create( array(
    245245                        'name' => 'Foo',
    246246                        'slug' => 'foo',
    247247                        'taxonomy' => 'wptests_tax',
    248248                ) );
    249249
    250                 $t2 = self::$factory->term->create( array(
     250                $t2 = self::factory()->term->create( array(
    251251                        'name' => 'Bar',
    252252                        'slug' => 'bar',
    253253                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    266266         */
    267267        public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_non_hierarchical_taxonomy() {
    268268                register_taxonomy( 'wptests_tax', 'post' );
    269                 $t1 = self::$factory->term->create( array(
     269                $t1 = self::factory()->term->create( array(
    270270                        'name' => 'Foo',
    271271                        'slug' => 'foo',
    272272                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    288288         */
    289289        public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_non_hierarchical_taxonomy() {
    290290                register_taxonomy( 'wptests_tax', 'post' );
    291                 $t1 = self::$factory->term->create( array(
     291                $t1 = self::factory()->term->create( array(
    292292                        'name' => 'Foo',
    293293                        'slug' => 'foo',
    294294                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    305305         */
    306306        public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_hierarchical_taxonomy() {
    307307                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    308                 $t1 = self::$factory->term->create( array(
     308                $t1 = self::factory()->term->create( array(
    309309                        'name' => 'Foo',
    310310                        'slug' => 'foo',
    311311                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    324324         */
    325325        public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_at_same_hierarchy_level_in_hierarchical_taxonomy() {
    326326                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    327                 $t1 = self::$factory->term->create( array(
     327                $t1 = self::factory()->term->create( array(
    328328                        'name' => 'Foo',
    329329                        'slug' => 'foo',
    330330                        'taxonomy' => 'wptests_tax',
    331331                ) );
    332332
    333                 $t2 = self::$factory->term->create( array(
     333                $t2 = self::factory()->term->create( array(
    334334                        'name' => 'Bar',
    335335                        'slug' => 'bar',
    336336                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    349349         */
    350350        public function test_wp_insert_term_should_allow_duplicate_names_when_slug_is_a_duplicate_of_a_term_at_different_hierarchy_level_in_hierarchical_taxonomy() {
    351351                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    352                 $t1 = self::$factory->term->create( array(
     352                $t1 = self::factory()->term->create( array(
    353353                        'name' => 'Foo',
    354354                        'slug' => 'foo',
    355355                        'taxonomy' => 'wptests_tax',
    356356                ) );
    357357
    358                 $t2 = self::$factory->term->create();
     358                $t2 = self::factory()->term->create();
    359359
    360                 $t3 = self::$factory->term->create( array(
     360                $t3 = self::factory()->term->create( array(
    361361                        'name' => 'Bar',
    362362                        'slug' => 'bar',
    363363                        'parent' => $t2,
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    381381         */
    382382        public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_hierarchical_taxonomy() {
    383383                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    384                 $t1 = self::$factory->term->create( array(
     384                $t1 = self::factory()->term->create( array(
    385385                        'name' => 'Foo',
    386386                        'slug' => 'foo',
    387387                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    403403         */
    404404        public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_hierarchical_taxonomy() {
    405405                register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
    406                 $t1 = self::$factory->term->create( array(
     406                $t1 = self::factory()->term->create( array(
    407407                        'name' => 'Foo',
    408408                        'slug' => 'foo',
    409409                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    419419         */
    420420        public function test_wp_insert_term_duplicate_slug_same_taxonomy() {
    421421                register_taxonomy( 'wptests_tax', 'post' );
    422                 $t = self::$factory->term->create( array(
     422                $t = self::factory()->term->create( array(
    423423                        'name' => 'Foo',
    424424                        'slug' => 'foo',
    425425                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    443443        public function test_wp_insert_term_duplicate_slug_different_taxonomy() {
    444444                register_taxonomy( 'wptests_tax', 'post' );
    445445                register_taxonomy( 'wptests_tax_2', 'post' );
    446                 $t = self::$factory->term->create( array(
     446                $t = self::factory()->term->create( array(
    447447                        'name' => 'Foo',
    448448                        'slug' => 'foo',
    449449                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    473473
    474474                register_taxonomy( 'wptests_tax', 'post' );
    475475                register_taxonomy( 'wptests_tax_2', 'post' );
    476                 $t = self::$factory->term->create( array(
     476                $t = self::factory()->term->create( array(
    477477                        'name' => 'Foo',
    478478                        'slug' => 'foo',
    479479                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    501501
    502502        public function test_wp_insert_term_alias_of_no_term_group() {
    503503                register_taxonomy( 'wptests_tax', 'post' );
    504                 $t1 = self::$factory->term->create( array(
     504                $t1 = self::factory()->term->create( array(
    505505                        'taxonomy' => 'wptests_tax',
    506506                ) );
    507507                $term_1 = get_term( $t1, 'wptests_tax' );
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    523523
    524524        public function test_wp_insert_term_alias_of_existing_term_group() {
    525525                register_taxonomy( 'wptests_tax', 'post' );
    526                 $t1 = self::$factory->term->create( array(
     526                $t1 = self::factory()->term->create( array(
    527527                        'taxonomy' => 'wptests_tax',
    528528                ) );
    529529                $term_1 = get_term( $t1, 'wptests_tax' );
    530530
    531                 $t2 = self::$factory->term->create( array(
     531                $t2 = self::factory()->term->create( array(
    532532                        'taxonomy' => 'wptests_tax',
    533533                        'alias_of' => $term_1->slug,
    534534                ) );
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    591591                        'hierarchical' => true,
    592592                ) );
    593593
    594                 $t = self::$factory->term->create( array(
     594                $t = self::factory()->term->create( array(
    595595                        'taxonomy' => 'wptests_tax',
    596596                ) );
    597597
    class Tests_Term_WpInsertTerm extends WP_UnitTestCase { 
    623623        public function test_wp_insert_term_with_and_without_accents() {
    624624                register_taxonomy( 'wptests_tax', 'post' );
    625625
    626                 $t1 = self::$factory->term->create( array(
     626                $t1 = self::factory()->term->create( array(
    627627                        'name' => 'Foó',
    628628                        'taxonomy' => 'wptests_tax',
    629629                ) );
    630                 $t2 = self::$factory->term->create( array(
     630                $t2 = self::factory()->term->create( array(
    631631                        'name' => 'Foo',
    632632                        'taxonomy' => 'wptests_tax',
    633633                ) );
  • tests/phpunit/tests/term/wpUniqueTermSlug.php

    diff --git tests/phpunit/tests/term/wpUniqueTermSlug.php tests/phpunit/tests/term/wpUniqueTermSlug.php
    index 98bca8a..2d5291c 100644
    class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { 
    1111        }
    1212
    1313        public function test_unique_slug_should_be_unchanged() {
    14                 $term = self::$factory->term->create_and_get( array(
     14                $term = self::factory()->term->create_and_get( array(
    1515                        'taxonomy' => 'wptests_tax1',
    1616                        'name' => 'foo',
    1717                        'slug' => 'foo',
    class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { 
    2222        }
    2323
    2424        public function test_nonunique_slug_in_different_taxonomy_should_be_unchanged() {
    25                 $term1 = self::$factory->term->create( array(
     25                $term1 = self::factory()->term->create( array(
    2626                        'taxonomy' => 'wptests_tax2',
    2727                        'name' => 'bar',
    2828                        'slug' => 'bar',
    2929                ) );
    3030
    31                 $term2 = self::$factory->term->create( array(
     31                $term2 = self::factory()->term->create( array(
    3232                        'taxonomy' => 'wptests_tax1',
    3333                        'name' => 'foo',
    3434                        'slug' => 'foo',
    class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { 
    4040        }
    4141
    4242        public function test_nonunique_slug_in_same_nonhierarchical_taxonomy_should_be_changed() {
    43                 $term1 = self::$factory->term->create( array(
     43                $term1 = self::factory()->term->create( array(
    4444                        'taxonomy' => 'wptests_tax1',
    4545                        'name' => 'bar',
    4646                        'slug' => 'bar',
    4747                ) );
    4848
    49                 $term2 = self::$factory->term->create( array(
     49                $term2 = self::factory()->term->create( array(
    5050                        'taxonomy' => 'wptests_tax1',
    5151                        'name' => 'foo',
    5252                        'slug' => 'foo',
    class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { 
    5858        }
    5959
    6060        public function test_nonunique_slug_in_same_hierarchical_taxonomy_with_same_parent_should_be_suffixed_with_parent_slug() {
    61                 $parent = self::$factory->term->create( array(
     61                $parent = self::factory()->term->create( array(
    6262                        'taxonomy' => 'wptests_tax2',
    6363                        'slug' => 'parent-term',
    6464                ) );
    6565
    66                 $term1 = self::$factory->term->create( array(
     66                $term1 = self::factory()->term->create( array(
    6767                        'taxonomy' => 'wptests_tax2',
    6868                        'name' => 'bar',
    6969                        'slug' => 'bar',
    7070                        'parent' => $parent,
    7171                ) );
    7272
    73                 $term2 = self::$factory->term->create( array(
     73                $term2 = self::factory()->term->create( array(
    7474                        'taxonomy' => 'wptests_tax2',
    7575                        'name' => 'foo',
    7676                        'slug' => 'foo',
    class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { 
    8383        }
    8484
    8585        public function test_nonunique_slug_in_same_hierarchical_taxonomy_at_different_level_of_hierarchy_should_be_suffixed_with_number() {
    86                 $parent = self::$factory->term->create( array(
     86                $parent = self::factory()->term->create( array(
    8787                        'taxonomy' => 'wptests_tax2',
    8888                        'slug' => 'parent-term',
    8989                ) );
    9090
    91                 $term1 = self::$factory->term->create( array(
     91                $term1 = self::factory()->term->create( array(
    9292                        'taxonomy' => 'wptests_tax2',
    9393                        'name' => 'bar',
    9494                        'slug' => 'bar',
    9595                        'parent' => $parent,
    9696                ) );
    9797
    98                 $term2 = self::$factory->term->create( array(
     98                $term2 = self::factory()->term->create( array(
    9999                        'taxonomy' => 'wptests_tax2',
    100100                        'name' => 'foo',
    101101                        'slug' => 'foo',
  • tests/phpunit/tests/term/wpUpdateTerm.php

    diff --git tests/phpunit/tests/term/wpUpdateTerm.php tests/phpunit/tests/term/wpUpdateTerm.php
    index 047fa9a..4d9d17b 100644
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    2020
    2121        public function test_wp_update_term_unslash_name() {
    2222                register_taxonomy( 'wptests_tax', 'post' );
    23                 $t = self::$factory->term->create( array(
     23                $t = self::factory()->term->create( array(
    2424                        'taxonomy' => 'wptests_tax',
    2525                ) );
    2626
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    3636
    3737        public function test_wp_update_term_unslash_description() {
    3838                register_taxonomy( 'wptests_tax', 'post' );
    39                 $t = self::$factory->term->create( array(
     39                $t = self::factory()->term->create( array(
    4040                        'taxonomy' => 'wptests_tax',
    4141                ) );
    4242
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    5252
    5353        public function test_wp_update_term_name_empty_string() {
    5454                register_taxonomy( 'wptests_tax', 'post' );
    55                 $t = self::$factory->term->create( array(
     55                $t = self::factory()->term->create( array(
    5656                        'taxonomy' => 'wptests_tax',
    5757                ) );
    5858
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    7676
    7777                $this->assertNull( term_exists( $fake_term_id, 'wptests_tax' ) );
    7878
    79                 $t = self::$factory->term->create( array(
     79                $t = self::factory()->term->create( array(
    8080                        'taxonomy' => 'wptests_tax',
    8181                ) );
    8282
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    9494
    9595        public function test_wp_update_term_slug_empty_string_while_not_updating_name() {
    9696                register_taxonomy( 'wptests_tax', 'post' );
    97                 $t = self::$factory->term->create( array(
     97                $t = self::factory()->term->create( array(
    9898                        'taxonomy' => 'wptests_tax',
    9999                        'name' => 'Foo Bar',
    100100                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    110110
    111111        public function test_wp_update_term_slug_empty_string_while_updating_name() {
    112112                register_taxonomy( 'wptests_tax', 'post' );
    113                 $t = self::$factory->term->create( array(
     113                $t = self::factory()->term->create( array(
    114114                        'taxonomy' => 'wptests_tax',
    115115                ) );
    116116
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    126126
    127127        public function test_wp_update_term_slug_set_slug() {
    128128                register_taxonomy( 'wptests_tax', 'post' );
    129                 $t = self::$factory->term->create( array(
     129                $t = self::factory()->term->create( array(
    130130                        'taxonomy' => 'wptests_tax',
    131131                ) );
    132132
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    145145        public function test_wp_update_term_should_not_create_duplicate_slugs_within_the_same_taxonomy() {
    146146                register_taxonomy( 'wptests_tax', 'post' );
    147147
    148                 $t1 = self::$factory->term->create( array(
     148                $t1 = self::factory()->term->create( array(
    149149                        'name' => 'Foo',
    150150                        'slug' => 'foo',
    151151                        'taxonomy' => 'wptests_tax',
    152152                ) );
    153153
    154                 $t2 = self::$factory->term->create( array(
     154                $t2 = self::factory()->term->create( array(
    155155                        'name' => 'Bar',
    156156                        'slug' => 'bar',
    157157                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    172172                register_taxonomy( 'wptests_tax', 'post' );
    173173                register_taxonomy( 'wptests_tax_2', 'post' );
    174174
    175                 $t1 = self::$factory->term->create( array(
     175                $t1 = self::factory()->term->create( array(
    176176                        'name' => 'Foo',
    177177                        'slug' => 'foo',
    178178                        'taxonomy' => 'wptests_tax',
    179179                ) );
    180180
    181                 $t2 = self::$factory->term->create( array(
     181                $t2 = self::factory()->term->create( array(
    182182                        'name' => 'Foo',
    183183                        'slug' => 'bar',
    184184                        'taxonomy' => 'wptests_tax_2',
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    202202                register_taxonomy( 'wptests_tax', 'post' );
    203203                register_taxonomy( 'wptests_tax_2', 'post' );
    204204
    205                 $t1 = self::$factory->term->create( array(
     205                $t1 = self::factory()->term->create( array(
    206206                        'name' => 'Foo',
    207207                        'slug' => 'foo',
    208208                        'taxonomy' => 'wptests_tax',
    209209                ) );
    210210
    211                 $t2 = self::$factory->term->create( array(
     211                $t2 = self::factory()->term->create( array(
    212212                        'name' => 'Bar',
    213213                        'slug' => 'bar',
    214214                        'taxonomy' => 'wptests_tax_2',
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    232232                        'hierarchical' => true,
    233233                ) );
    234234
    235                 $t1 = self::$factory->term->create( array(
     235                $t1 = self::factory()->term->create( array(
    236236                        'name' => 'Foo',
    237237                        'slug' => 'foo',
    238238                        'taxonomy' => 'wptests_tax',
    239239                ) );
    240240
    241                 $t2 = self::$factory->term->create( array(
     241                $t2 = self::factory()->term->create( array(
    242242                        'name' => 'Bar',
    243243                        'slug' => 'bar',
    244244                        'taxonomy' => 'wptests_tax',
    245245                        'parent' => $t1,
    246246                ) );
    247247
    248                 $t3 = self::$factory->term->create( array(
     248                $t3 = self::factory()->term->create( array(
    249249                        'name' => 'Bar Child',
    250250                        'slug' => 'bar-child',
    251251                        'taxonomy' => 'wptests_tax',
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    282282                        array( '%d' )
    283283                );
    284284
    285                 $posts = self::$factory->post->create_many( 2 );
     285                $posts = self::factory()->post->create_many( 2 );
    286286                wp_set_object_terms( $posts[0], array( 'Foo' ), 'wptests_tax' );
    287287                wp_set_object_terms( $posts[1], array( 'Foo' ), 'wptests_tax_2' );
    288288
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    302302
    303303        public function test_wp_update_term_alias_of_no_term_group() {
    304304                register_taxonomy( 'wptests_tax', 'post' );
    305                 $t1 = self::$factory->term->create( array(
     305                $t1 = self::factory()->term->create( array(
    306306                        'taxonomy' => 'wptests_tax',
    307307                ) );
    308308                $term_1 = get_term( $t1, 'wptests_tax' );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    323323
    324324        public function test_wp_update_term_alias_of_existing_term_group() {
    325325                register_taxonomy( 'wptests_tax', 'post' );
    326                 $t1 = self::$factory->term->create( array(
     326                $t1 = self::factory()->term->create( array(
    327327                        'taxonomy' => 'wptests_tax',
    328328                ) );
    329329                $term_1 = get_term( $t1, 'wptests_tax' );
    330330
    331                 $t2 = self::$factory->term->create( array(
     331                $t2 = self::factory()->term->create( array(
    332332                        'taxonomy' => 'wptests_tax',
    333333                        'alias_of' => $term_1->slug,
    334334                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    359359
    360360        public function test_wp_update_term_slug_same_as_old_slug() {
    361361                register_taxonomy( 'wptests_tax', 'post' );
    362                 $t = self::$factory->term->create( array(
     362                $t = self::factory()->term->create( array(
    363363                        'taxonomy' => 'wptests_tax',
    364364                        'slug' => 'foo',
    365365                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    377377
    378378        public function test_wp_update_term_duplicate_slug_generated_due_to_empty_slug_param() {
    379379                register_taxonomy( 'wptests_tax', 'post' );
    380                 $t1 = self::$factory->term->create( array(
     380                $t1 = self::factory()->term->create( array(
    381381                        'taxonomy' => 'wptests_tax',
    382382                        'slug' => 'foo-bar',
    383383                ) );
    384                 $t2 = self::$factory->term->create( array(
     384                $t2 = self::factory()->term->create( array(
    385385                        'taxonomy' => 'wptests_tax',
    386386                        'name' => 'not foo bar',
    387387                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    402402                register_taxonomy( 'wptests_tax', 'post', array(
    403403                        'hierarchical' => true,
    404404                ) );
    405                 $p = self::$factory->term->create( array(
     405                $p = self::factory()->term->create( array(
    406406                        'taxonomy' => 'wptests_tax',
    407407                ) );
    408                 $t1 = self::$factory->term->create( array(
     408                $t1 = self::factory()->term->create( array(
    409409                        'taxonomy' => 'wptests_tax',
    410410                        'slug' => 'foo-bar',
    411411                ) );
    412                 $t2 = self::$factory->term->create( array(
     412                $t2 = self::factory()->term->create( array(
    413413                        'taxonomy' => 'wptests_tax',
    414414                ) );
    415415
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    428428
    429429        public function test_wp_update_term_duplicate_slug_failure() {
    430430                register_taxonomy( 'wptests_tax', 'post' );
    431                 $t1 = self::$factory->term->create( array(
     431                $t1 = self::factory()->term->create( array(
    432432                        'taxonomy' => 'wptests_tax',
    433433                        'slug' => 'foo-bar',
    434434                ) );
    435                 $t2 = self::$factory->term->create( array(
     435                $t2 = self::factory()->term->create( array(
    436436                        'taxonomy' => 'wptests_tax',
    437437                        'slug' => 'my-old-slug',
    438438                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    451451
    452452        public function test_wp_update_term_should_return_term_id_and_term_taxonomy_id() {
    453453                register_taxonomy( 'wptests_tax', 'post' );
    454                 $t = self::$factory->term->create( array(
     454                $t = self::factory()->term->create( array(
    455455                        'taxonomy' => 'wptests_tax',
    456456                ) );
    457457                $found = wp_update_term( $t, 'wptests_tax', array(
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    477477         */
    478478        public function test_wp_update_term_should_return_int_values_for_term_id_and_term_taxonomy_id() {
    479479                register_taxonomy( 'wptests_tax', 'post' );
    480                 $t = self::$factory->term->create( array(
     480                $t = self::factory()->term->create( array(
    481481                        'taxonomy' => 'wptests_tax',
    482482                ) );
    483483                $found = wp_update_term( $t, 'wptests_tax', array(
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    491491        public function test_wp_update_term_should_clean_object_term_cache() {
    492492                register_taxonomy( 'wptests_tax_for_post', 'post' );
    493493                register_taxonomy( 'wptests_tax_for_page', 'page' );
    494                 $post = self::$factory->post->create();
    495                 $page = self::$factory->post->create( array(
     494                $post = self::factory()->post->create();
     495                $page = self::factory()->post->create( array(
    496496                        'post_type' => 'page',
    497497                ) );
    498498
    499                 $t_for_post = self::$factory->term->create( array(
     499                $t_for_post = self::factory()->term->create( array(
    500500                        'taxonomy' => 'wptests_tax_for_post',
    501501                ) );
    502                 $t_for_page = self::$factory->term->create( array(
     502                $t_for_page = self::factory()->term->create( array(
    503503                        'taxonomy' => 'wptests_tax_for_page',
    504504                ) );
    505505
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    527527                        'hierarchical' => true,
    528528                ) );
    529529
    530                 $t1 = self::$factory->term->create( array(
     530                $t1 = self::factory()->term->create( array(
    531531                        'taxonomy' => 'wptests_tax',
    532532                ) );
    533                 $t2 = self::$factory->term->create( array(
     533                $t2 = self::factory()->term->create( array(
    534534                        'taxonomy' => 'wptests_tax',
    535535                ) );
    536536
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    567567                        'hierarchical' => true,
    568568                ) );
    569569
    570                 $t1 = self::$factory->term->create( array(
     570                $t1 = self::factory()->term->create( array(
    571571                        'taxonomy' => 'wptests_tax',
    572572                        'slug' => 'parent-term',
    573573                ) );
    574574
    575                 $t2 = self::$factory->term->create( array(
     575                $t2 = self::factory()->term->create( array(
    576576                        'taxonomy' => 'wptests_tax',
    577577                        'slug' => 'foo',
    578578                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    599599                        'hierarchical' => true,
    600600                ) );
    601601
    602                 $t1 = self::$factory->term->create( array(
     602                $t1 = self::factory()->term->create( array(
    603603                        'taxonomy' => 'wptests_tax',
    604604                        'slug' => 'parent-term',
    605605                ) );
    606606
    607607                // Same slug but in a different tax.
    608                 $t2 = self::$factory->term->create( array(
     608                $t2 = self::factory()->term->create( array(
    609609                        'taxonomy' => 'wptests_tax_2',
    610610                        'slug' => 'foo',
    611611                ) );
    612612
    613                 $t3 = self::$factory->term->create( array(
     613                $t3 = self::factory()->term->create( array(
    614614                        'taxonomy' => 'wptests_tax',
    615615                        'slug' => 'foo',
    616616                ) );
    class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { 
    630630         * @ticket 31954
    631631         */
    632632        public function test_wp_update_term_with_null_get_term() {
    633                 $t = self::$factory->term->create( array( 'taxonomy' => 'category' ) );
     633                $t = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
    634634                $found = wp_update_term( $t, 'post_tag', array( 'slug' => 'foo' ) );
    635635
    636636                $this->assertWPError( $found );
  • tests/phpunit/tests/url.php

    diff --git tests/phpunit/tests/url.php tests/phpunit/tests/url.php
    index baae9d6..3c3c19a 100644
    class Tests_URL extends WP_UnitTestCase { 
    272272
    273273        public function test_get_adjacent_post() {
    274274                $now = time();
    275                 $post_id = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    276                 $post_id2 = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     275                $post_id = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     276                $post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    277277
    278278                if ( ! isset( $GLOBALS['post'] ) )
    279279                        $GLOBALS['post'] = null;
    class Tests_URL extends WP_UnitTestCase { 
    305305         * @ticket 30287
    306306         */
    307307        public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() {
    308                 $u = self::$factory->user->create( array( 'role' => 'author' ) );
     308                $u = self::factory()->user->create( array( 'role' => 'author' ) );
    309309                $old_uid = get_current_user_id();
    310310                wp_set_current_user( $u );
    311311
    312312                $now = time();
    313                 $p1 = self::$factory->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    314                 $p2 = self::$factory->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     313                $p1 = self::factory()->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     314                $p2 = self::factory()->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    315315
    316316                if ( ! isset( $GLOBALS['post'] ) ) {
    317317                        $GLOBALS['post'] = null;
    class Tests_URL extends WP_UnitTestCase { 
    331331         * @ticket 30287
    332332         */
    333333        public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() {
    334                 $u1 = self::$factory->user->create( array( 'role' => 'author' ) );
    335                 $u2 = self::$factory->user->create( array( 'role' => 'administrator' ) );
     334                $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
     335                $u2 = self::factory()->user->create( array( 'role' => 'administrator' ) );
    336336                $old_uid = get_current_user_id();
    337337                wp_set_current_user( $u2 );
    338338
    339339                $now = time();
    340                 $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    341                 $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     340                $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     341                $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    342342
    343343                if ( ! isset( $GLOBALS['post'] ) ) {
    344344                        $GLOBALS['post'] = null;
    class Tests_URL extends WP_UnitTestCase { 
    358358         * @ticket 30287
    359359         */
    360360        public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() {
    361                 $u1 = self::$factory->user->create( array( 'role' => 'author' ) );
    362                 $u2 = self::$factory->user->create( array( 'role' => 'author' ) );
     361                $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
     362                $u2 = self::factory()->user->create( array( 'role' => 'author' ) );
    363363                $old_uid = get_current_user_id();
    364364                wp_set_current_user( $u2 );
    365365
    366366                $now = time();
    367                 $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) );
    368                 $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    369                 $p3 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     367                $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) );
     368                $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     369                $p3 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    370370
    371371                if ( ! isset( $GLOBALS['post'] ) ) {
    372372                        $GLOBALS['post'] = null;
  • tests/phpunit/tests/user.php

    diff --git tests/phpunit/tests/user.php tests/phpunit/tests/user.php
    index 07bbabd..82c99ef 100644
    class Tests_User extends WP_UnitTestCase { 
    4343                // add one of each user role
    4444                $nusers = array();
    4545                foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) {
    46                         $id = self::$factory->user->create( array( 'role' => $role ) );
     46                        $id = self::factory()->user->create( array( 'role' => $role ) );
    4747                        $nusers[ $id ] = $id;
    4848                }
    4949
    class Tests_User extends WP_UnitTestCase { 
    244244                );
    245245
    246246                foreach ( $roles as $role => $level ) {
    247                         $user_id = self::$factory->user->create( array( 'role' => $role ) );
     247                        $user_id = self::factory()->user->create( array( 'role' => $role ) );
    248248                        $user = new WP_User( $user_id );
    249249
    250250                        $this->assertTrue( isset( $user->user_level ) );
    class Tests_User extends WP_UnitTestCase { 
    292292        }
    293293
    294294        function test_get() {
    295                 $user_id = self::$factory->user->create( array(
     295                $user_id = self::factory()->user->create( array(
    296296                        'role' => 'author',
    297297                        'user_login' => 'test_wp_user_get',
    298298                        'user_pass' => 'password',
    class Tests_User extends WP_UnitTestCase { 
    310310        }
    311311
    312312        function test_has_prop() {
    313                 $user_id = self::$factory->user->create( array(
     313                $user_id = self::factory()->user->create( array(
    314314                        'role' => 'author',
    315315                        'user_login' => 'test_wp_user_has_prop',
    316316                        'user_pass' => 'password',
    class Tests_User extends WP_UnitTestCase { 
    327327        }
    328328
    329329        function test_update_user() {
    330                 $user_id = self::$factory->user->create( array(
     330                $user_id = self::factory()->user->create( array(
    331331                        'role' => 'author',
    332332                        'user_login' => 'test_wp_update_user',
    333333                        'user_pass' => 'password',
    class Tests_User extends WP_UnitTestCase { 
    383383        function test_global_userdata() {
    384384                global $userdata, $wpdb;
    385385
    386                 $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) );
     386                $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    387387                wp_set_current_user( $user_id );
    388388
    389389                $this->assertNotEmpty( $userdata );
    class Tests_User extends WP_UnitTestCase { 
    497497         * @ticket 21431
    498498         */
    499499        function test_count_many_users_posts() {
    500                 $user_id_a = self::$factory->user->create( array( 'role' => 'author' ) );
    501                 $user_id_b = self::$factory->user->create( array( 'role' => 'author' ) );
    502                 $post_id_a = self::$factory->post->create( array( 'post_author' => $user_id_a ) );
    503                 $post_id_b = self::$factory->post->create( array( 'post_author' => $user_id_b ) );
    504                 $post_id_c = self::$factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
     500                $user_id_a = self::factory()->user->create( array( 'role' => 'author' ) );
     501                $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) );
     502                $post_id_a = self::factory()->post->create( array( 'post_author' => $user_id_a ) );
     503                $post_id_b = self::factory()->post->create( array( 'post_author' => $user_id_b ) );
     504                $post_id_c = self::factory()->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
    505505
    506506                wp_set_current_user( $user_id_a );
    507507                $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', false );
    class Tests_User extends WP_UnitTestCase { 
    771771         * @ticket 33793
    772772         */
    773773        public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() {
    774                 $u1 = self::$factory->user->create( array(
     774                $u1 = self::factory()->user->create( array(
    775775                        'user_nicename' => str_repeat( 'a', 50 ),
    776776                ) );
    777777
    class Tests_User extends WP_UnitTestCase { 
    792792         * @ticket 33793
    793793         */
    794794        public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() {
    795                 $users = self::$factory->user->create_many( 4, array(
     795                $users = self::factory()->user->create_many( 4, array(
    796796                        'user_nicename' => str_repeat( 'a', 50 ),
    797797                ) );
    798798
    class Tests_User extends WP_UnitTestCase { 
    876876         */
    877877        function test_email_case() {
    878878                // Create a test user with a lower-case email address.
    879                 $user_id = self::$factory->user->create( array(
     879                $user_id = self::factory()->user->create( array(
    880880                        'user_email' => 'test@test.com',
    881881                ) );
    882882
    class Tests_User extends WP_UnitTestCase { 
    895895         */
    896896        function test_email_change() {
    897897                // Create a test user.
    898                 $user_id = self::$factory->user->create( array(
     898                $user_id = self::factory()->user->create( array(
    899899                        'user_email' => 'test@test.com',
    900900                ) );
    901901
    class Tests_User extends WP_UnitTestCase { 
    983983         * @expectedDeprecated wp_new_user_notification
    984984         */
    985985        function test_wp_new_user_notification_old_signature_throws_deprecated_warning() {
    986                 $user = self::$factory->user->create( array(
     986                $user = self::factory()->user->create( array(
    987987                        'role'       => 'author',
    988988                        'user_login' => 'test_wp_new_user_notification',
    989989                        'user_pass'  => 'password',
  • tests/phpunit/tests/user/author.php

    diff --git tests/phpunit/tests/user/author.php tests/phpunit/tests/user/author.php
    index d236d2a..73ae3b6 100644
    class Tests_User_Author_Template extends WP_UnitTestCase { 
    1515        function setUp() {
    1616                parent::setUp();
    1717
    18                 $this->author_id = self::$factory->user->create( array(
     18                $this->author_id = self::factory()->user->create( array(
    1919                        'role' => 'author',
    2020                        'user_login' => 'test_author',
    2121                        'description' => 'test_author',
    class Tests_User_Author_Template extends WP_UnitTestCase { 
    3131                );
    3232
    3333                // insert a post and make sure the ID is ok
    34                 $this->post_id = self::$factory->post->create( $post );
     34                $this->post_id = self::factory()->post->create( $post );
    3535
    3636                setup_postdata( get_post( $this->post_id ) );
    3737        }
    class Tests_User_Author_Template extends WP_UnitTestCase { 
    9090        function test_get_the_author_posts_with_custom_post_type() {
    9191                register_post_type( 'wptests_pt' );
    9292
    93                 $cpt_ids = self::$factory->post->create_many( 2, array(
     93                $cpt_ids = self::factory()->post->create_many( 2, array(
    9494                        'post_author' => $this->author_id,
    9595                        'post_type'   => 'wptests_pt',
    9696                ) );
    class Tests_User_Author_Template extends WP_UnitTestCase { 
    105105         * @ticket 30355
    106106         */
    107107        public function test_get_the_author_posts_link_no_permalinks() {
    108                 $author = self::$factory->user->create_and_get( array(
     108                $author = self::factory()->user->create_and_get( array(
    109109                        'display_name'  => 'Foo',
    110110                        'user_nicename' => 'bar'
    111111                ) );
    class Tests_User_Author_Template extends WP_UnitTestCase { 
    129129        public function test_get_the_author_posts_link_with_permalinks() {
    130130                $this->set_permalink_structure( '/%postname%/' );
    131131
    132                 $author = self::$factory->user->create_and_get( array(
     132                $author = self::factory()->user->create_and_get( array(
    133133                        'display_name'  => 'Foo',
    134134                        'user_nicename' => 'bar'
    135135                ) );
  • tests/phpunit/tests/user/capabilities.php

    diff --git tests/phpunit/tests/user/capabilities.php tests/phpunit/tests/user/capabilities.php
    index 0d1960b..99b0c56 100644
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    222222        // test the default roles and caps
    223223        function test_all_roles_and_caps() {
    224224                $users = array(
    225                         'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ),
    226                         'editor'        => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ),
    227                         'author'        => self::$factory->user->create_and_get( array( 'role' => 'author' ) ),
    228                         'contributor'   => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ),
    229                         'subscriber'    => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ),
     225                        'administrator' => self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ),
     226                        'editor'        => self::factory()->user->create_and_get( array( 'role' => 'editor' ) ),
     227                        'author'        => self::factory()->user->create_and_get( array( 'role' => 'author' ) ),
     228                        'contributor'   => self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ),
     229                        'subscriber'    => self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ),
    230230                );
    231231                $caps = $this->getCapsAndRoles();
    232232
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    258258        // special case for the link manager
    259259        function test_link_manager_caps() {
    260260                $users = array(
    261                         'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ),
    262                         'editor'        => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ),
    263                         'author'        => self::$factory->user->create_and_get( array( 'role' => 'author' ) ),
    264                         'contributor'   => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ),
    265                         'subscriber'    => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ),
     261                        'administrator' => self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ),
     262                        'editor'        => self::factory()->user->create_and_get( array( 'role' => 'editor' ) ),
     263                        'author'        => self::factory()->user->create_and_get( array( 'role' => 'author' ) ),
     264                        'contributor'   => self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ),
     265                        'subscriber'    => self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ),
    266266                );
    267267                $caps = array(
    268268                        'manage_links' => array( 'administrator', 'editor' ),
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    305305                }
    306306                $caps = $this->getCapsAndRoles();
    307307
    308                 $user = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) );
     308                $user = self::factory()->user->create_and_get( array( 'role' => 'administrator' ) );
    309309                grant_super_admin( $user->ID );
    310310
    311311                $this->assertTrue( is_super_admin( $user->ID ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    321321
    322322        // a role that doesn't exist
    323323        function test_bogus_role() {
    324                 $user = self::$factory->user->create_and_get( array( 'role' => 'invalid_role' ) );
     324                $user = self::factory()->user->create_and_get( array( 'role' => 'invalid_role' ) );
    325325
    326326                // make sure the user is valid
    327327                $this->assertTrue( $user->exists(), "User does not exist" );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    339339
    340340        // a user with multiple roles
    341341        function test_user_subscriber_contributor() {
    342                 $user = self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) );
     342                $user = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) );
    343343
    344344                // make sure the user is valid
    345345                $this->assertTrue( $user->exists(), "User does not exist" );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    372372                $this->_flush_roles();
    373373                $this->assertTrue( $wp_roles->is_role( $role_name ) );
    374374
    375                 $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) );
     375                $user = self::factory()->user->create_and_get( array( 'role' => $role_name ) );
    376376
    377377                // make sure the user is valid
    378378                $this->assertTrue( $user->exists(), "User does not exist" );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    409409                $this->_flush_roles();
    410410                $this->assertTrue( $wp_roles->is_role( $role_name ) );
    411411
    412                 $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) );
     412                $user = self::factory()->user->create_and_get( array( 'role' => $role_name ) );
    413413
    414414                // make sure the user is valid
    415415                $this->assertTrue( $user->exists(), "User does not exist" );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    446446                $this->assertTrue( $wp_roles->is_role($role_name) );
    447447
    448448                // assign a user to that role
    449                 $id = self::$factory->user->create( array( 'role' => $role_name ) );
     449                $id = self::factory()->user->create( array( 'role' => $role_name ) );
    450450
    451451                // now add a cap to the role
    452452                $wp_roles->add_cap($role_name, 'sweep_floor');
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    484484                $this->assertTrue( $wp_roles->is_role($role_name) );
    485485
    486486                // assign a user to that role
    487                 $id = self::$factory->user->create( array( 'role' => $role_name ) );
     487                $id = self::factory()->user->create( array( 'role' => $role_name ) );
    488488
    489489                // now remove a cap from the role
    490490                $wp_roles->remove_cap($role_name, 'polish_doorknobs');
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    513513                // add an extra capability to a user
    514514
    515515                // there are two contributors
    516                 $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) );
    517                 $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) );
     516                $id_1 = self::factory()->user->create( array( 'role' => 'contributor' ) );
     517                $id_2 = self::factory()->user->create( array( 'role' => 'contributor' ) );
    518518
    519519                // user 1 has an extra capability
    520520                $user_1 = new WP_User($id_1);
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    550550                // add an extra capability to a user then remove it
    551551
    552552                // there are two contributors
    553                 $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) );
    554                 $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) );
     553                $id_1 = self::factory()->user->create( array( 'role' => 'contributor' ) );
     554                $id_2 = self::factory()->user->create( array( 'role' => 'contributor' ) );
    555555
    556556                // user 1 has an extra capability
    557557                $user_1 = new WP_User($id_1);
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    581581                // make sure the user_level is correctly set and changed with the user's role
    582582
    583583                // user starts as an author
    584                 $id = self::$factory->user->create( array( 'role' => 'author' ) );
     584                $id = self::factory()->user->create( array( 'role' => 'author' ) );
    585585                $user = new WP_User($id);
    586586                $this->assertTrue($user->exists(), "Problem getting user $id");
    587587
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    604604
    605605        function test_user_remove_all_caps() {
    606606                // user starts as an author
    607                 $id = self::$factory->user->create( array( 'role' => 'author' ) );
     607                $id = self::factory()->user->create( array( 'role' => 'author' ) );
    608608                $user = new WP_User($id);
    609609                $this->assertTrue($user->exists(), "Problem getting user $id");
    610610
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    646646                // simple tests for some common meta capabilities
    647647
    648648                // Make our author
    649                 $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
     649                $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
    650650
    651651                // make a post
    652                 $post = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) );
     652                $post = self::factory()->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) );
    653653
    654654                // the author of the post
    655655                $this->assertTrue($author->exists(), "Problem getting user $author->ID");
    656656
    657657                // add some other users
    658                 $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
    659                 $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
    660                 $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) );
    661                 $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) );
     658                $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     659                $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
     660                $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     661                $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) );
    662662
    663663                // administrators, editors and the post owner can edit it
    664664                $this->assertTrue($admin->has_cap('edit_post', $post));
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    732732         */
    733733        function test_authorless_post( $status ) {
    734734                // Make a post without an author
    735                 $post = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) );
     735                $post = self::factory()->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) );
    736736
    737737                // Add an editor and contributor
    738                 $editor = self::$factory->user->create_and_get( array( 'role' => 'editor' ) );
    739                 $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) );
     738                $editor = self::factory()->user->create_and_get( array( 'role' => 'editor' ) );
     739                $contributor = self::factory()->user->create_and_get( array( 'role' => 'contributor' ) );
    740740
    741741                // editor can edit, view, and trash
    742742                $this->assertTrue( $editor->has_cap( 'edit_post', $post ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    753753         * @ticket 16714
    754754         */
    755755        function test_create_posts_caps() {
    756                 $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
    757                 $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
    758                 $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
    759                 $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) );
    760                 $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) );
     756                $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
     757                $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     758                $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
     759                $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     760                $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) );
    761761
    762762                // create_posts isn't a real cap.
    763763                $this->assertFalse($admin->has_cap('create_posts'));
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    818818                // simple tests for some common meta capabilities
    819819
    820820                // Make our author
    821                 $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
     821                $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
    822822
    823823                // make a page
    824                 $page = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) );
     824                $page = self::factory()->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) );
    825825
    826826                // the author of the page
    827827                $this->assertTrue($author->exists(), "Problem getting user " . $author->ID);
    828828
    829829                // add some other users
    830                 $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
    831                 $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
    832                 $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) );
    833                 $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) );
     830                $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     831                $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
     832                $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     833                $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) );
    834834
    835835                // administrators, editors and the post owner can edit it
    836836                $this->assertTrue($admin->has_cap('edit_page', $page));
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    853853         * @ticket 21786
    854854         */
    855855        function test_negative_caps() {
    856                 $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) );
     856                $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
    857857                $author->add_cap( 'foo', false );
    858858                $this->assertTrue ( isset( $author->caps['foo'] ) );
    859859                $author->remove_cap( 'foo' );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    864864         * @ticket 18932
    865865         */
    866866        function test_set_role_same_role() {
    867                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     867                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    868868                $caps = $user->caps;
    869869                $this->assertNotEmpty( $user->caps );
    870870                $user->set_role( 'administrator' );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    875875        function test_current_user_can_for_blog() {
    876876                global $wpdb;
    877877
    878                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     878                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    879879                $old_uid = get_current_user_id();
    880880                wp_set_current_user( $user->ID );
    881881
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    890890                $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) );
    891891                $wpdb->suppress_errors( $suppress );
    892892
    893                 $blog_id = self::$factory->blog->create( array( 'user_id' => $user->ID ) );
     893                $blog_id = self::factory()->blog->create( array( 'user_id' => $user->ID ) );
    894894                $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) );
    895895                $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) );
    896896
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    904904                }
    905905
    906906                $orig_blog_id = get_current_blog_id();
    907                 $blog_id = self::$factory->blog->create();
     907                $blog_id = self::factory()->blog->create();
    908908
    909909                $this->_nullify_current_user();
    910910
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    932932         * @ticket 28374
    933933         */
    934934        function test_current_user_edit_caps() {
    935                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) );
     935                $user = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) );
    936936                wp_set_current_user( $user->ID );
    937937
    938938                $user->add_cap( 'publish_posts' );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    945945        }
    946946
    947947        function test_subscriber_cant_edit_posts() {
    948                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) );
     948                $user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    949949                wp_set_current_user( $user->ID );
    950950
    951                 $post = self::$factory->post->create( array( 'post_author' => 1 ) );
     951                $post = self::factory()->post->create( array( 'post_author' => 1 ) );
    952952
    953953                $this->assertFalse( current_user_can( 'edit_post', $post ) );
    954954                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    960960                        return;
    961961                }
    962962
    963                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
    964                 $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) );
     963                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     964                $other_user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    965965
    966966                wp_set_current_user( $user->ID );
    967967
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    974974                        return;
    975975                }
    976976
    977                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     977                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    978978
    979979                wp_set_current_user( $user->ID );
    980980
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    987987                        return;
    988988                }
    989989
    990                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     990                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    991991                $user->add_cap( 'manage_network_users' );
    992                 $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) );
     992                $other_user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    993993
    994994                wp_set_current_user( $user->ID );
    995995
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    10021002                        return;
    10031003                }
    10041004
    1005                 $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     1005                $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    10061006                $user->add_cap( 'manage_network_users' );
    1007                 $super_admin = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) );
     1007                $super_admin = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    10081008                grant_super_admin( $super_admin->ID );
    10091009
    10101010                wp_set_current_user( $user->ID );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    10171017         */
    10181018        function test_require_edit_others_posts_if_post_type_doesnt_exist() {
    10191019                register_post_type( 'existed' );
    1020                 $post_id = self::$factory->post->create( array( 'post_type' => 'existed' ) );
     1020                $post_id = self::factory()->post->create( array( 'post_type' => 'existed' ) );
    10211021                _unregister_post_type( 'existed' );
    10221022
    1023                 $subscriber_id = self::$factory->user->create( array( 'role' => 'subscriber' ) );
    1024                 $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     1023                $subscriber_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
     1024                $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    10251025
    10261026                $this->setExpectedIncorrectUsage( 'map_meta_cap' );
    10271027                foreach ( array( 'delete_post', 'edit_post', 'read_post', 'publish_post' ) as $cap ) {
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    10461046
    10471047                $cpt = get_post_type_object( 'page_capability' );
    10481048
    1049                 $admin       = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) );
    1050                 $editor      = self::$factory->user->create_and_get( array( 'role' => 'editor' ) );
    1051                 $author      = self::$factory->user->create_and_get( array( 'role' => 'author' ) );
    1052                 $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) );
     1049                $admin       = self::factory()->user->create_and_get( array( 'role' => 'administrator' ) );
     1050                $editor      = self::factory()->user->create_and_get( array( 'role' => 'editor' ) );
     1051                $author      = self::factory()->user->create_and_get( array( 'role' => 'author' ) );
     1052                $contributor = self::factory()->user->create_and_get( array( 'role' => 'contributor' ) );
    10531053
    10541054                $this->assertEquals( 'edit_pages', $cpt->cap->edit_posts );
    10551055                $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    10571057                $this->assertFalse( user_can( $author->ID, $cpt->cap->edit_posts ) );
    10581058                $this->assertFalse( user_can( $contributor->ID, $cpt->cap->edit_posts ) );
    10591059
    1060                 $admin_post = self::$factory->post->create_and_get( array(
     1060                $admin_post = self::factory()->post->create_and_get( array(
    10611061                        'post_author' => $admin->ID,
    10621062                        'post_type'   => 'page_capability',
    10631063                ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    10671067                $this->assertFalse( user_can( $author->ID, 'edit_post', $admin_post->ID ) );
    10681068                $this->assertFalse( user_can( $contributor->ID, 'edit_post', $admin_post->ID ) );
    10691069
    1070                 $author_post = self::$factory->post->create_and_get( array(
     1070                $author_post = self::factory()->post->create_and_get( array(
    10711071                        'post_author' => $author->ID,
    10721072                        'post_type'   => 'page_capability',
    10731073                ) );
  • tests/phpunit/tests/user/countUsers.php

    diff --git tests/phpunit/tests/user/countUsers.php tests/phpunit/tests/user/countUsers.php
    index 4a758f0..257a045 100644
    class Tests_User_CountUsers extends WP_UnitTestCase { 
    1717                }
    1818
    1919                // Setup users
    20                 $admin = self::$factory->user->create( array(
     20                $admin = self::factory()->user->create( array(
    2121                        'role' => 'administrator',
    2222                ) );
    23                 $editor = self::$factory->user->create( array(
     23                $editor = self::factory()->user->create( array(
    2424                        'role' => 'editor',
    2525                ) );
    26                 $author = self::$factory->user->create( array(
     26                $author = self::factory()->user->create( array(
    2727                        'role' => 'author',
    2828                ) );
    29                 $contributor = self::$factory->user->create( array(
     29                $contributor = self::factory()->user->create( array(
    3030                        'role' => 'contributor',
    3131                ) );
    32                 $subscriber = self::$factory->user->create( array(
     32                $subscriber = self::factory()->user->create( array(
    3333                        'role' => 'subscriber',
    3434                ) );
    35                 $none = self::$factory->user->create( array(
     35                $none = self::factory()->user->create( array(
    3636                        'role' => '',
    3737                ) );
    38                 $nobody = self::$factory->user->create( array(
     38                $nobody = self::factory()->user->create( array(
    3939                        'role' => '',
    4040                ) );
    4141
    class Tests_User_CountUsers extends WP_UnitTestCase { 
    6767                }
    6868
    6969                // Setup users
    70                 $admin = self::$factory->user->create( array(
     70                $admin = self::factory()->user->create( array(
    7171                        'role' => 'administrator',
    7272                ) );
    73                 $editor = self::$factory->user->create( array(
     73                $editor = self::factory()->user->create( array(
    7474                        'role' => 'editor',
    7575                ) );
    76                 $author = self::$factory->user->create( array(
     76                $author = self::factory()->user->create( array(
    7777                        'role' => 'author',
    7878                ) );
    79                 $contributor = self::$factory->user->create( array(
     79                $contributor = self::factory()->user->create( array(
    8080                        'role' => 'contributor',
    8181                ) );
    82                 $subscriber = self::$factory->user->create( array(
     82                $subscriber = self::factory()->user->create( array(
    8383                        'role' => 'subscriber',
    8484                ) );
    85                 $none = self::$factory->user->create( array(
     85                $none = self::factory()->user->create( array(
    8686                        'role' => '',
    8787                ) );
    88                 $nobody = self::$factory->user->create( array(
     88                $nobody = self::factory()->user->create( array(
    8989                        'role' => '',
    9090                ) );
    9191
    9292                // Setup blogs
    93                 $blog_1 = (int) self::$factory->blog->create( array(
     93                $blog_1 = (int) self::factory()->blog->create( array(
    9494                        'user_id' => $editor,
    9595                ) );
    96                 $blog_2 = (int) self::$factory->blog->create( array(
     96                $blog_2 = (int) self::factory()->blog->create( array(
    9797                        'user_id' => $author,
    9898                ) );
    9999
  • tests/phpunit/tests/user/dateQuery.php

    diff --git tests/phpunit/tests/user/dateQuery.php tests/phpunit/tests/user/dateQuery.php
    index 448bd59..07b6c3a 100644
    class Tests_User_DateQuery extends WP_UnitTestCase { 
    99         * @ticket 27283
    1010         */
    1111        public function test_user_registered() {
    12                 $u1 = self::$factory->user->create( array(
     12                $u1 = self::factory()->user->create( array(
    1313                        'user_registered' => '2012-02-14 05:05:05',
    1414                ) );
    15                 $u2 = self::$factory->user->create( array(
     15                $u2 = self::factory()->user->create( array(
    1616                        'user_registered' => '2013-02-14 05:05:05',
    1717                ) );
    1818
    class Tests_User_DateQuery extends WP_UnitTestCase { 
    3131         * @ticket 27283
    3232         */
    3333        public function test_user_registered_relation_or() {
    34                 $u1 = self::$factory->user->create( array(
     34                $u1 = self::factory()->user->create( array(
    3535                        'user_registered' => '2012-02-14 05:05:05',
    3636                ) );
    37                 $u2 = self::$factory->user->create( array(
     37                $u2 = self::factory()->user->create( array(
    3838                        'user_registered' => '2013-02-14 05:05:05',
    3939                ) );
    40                 $u3 = self::$factory->user->create( array(
     40                $u3 = self::factory()->user->create( array(
    4141                        'user_registered' => '2014-02-14 05:05:05',
    4242                ) );
    4343
  • tests/phpunit/tests/user/listAuthors.php

    diff --git tests/phpunit/tests/user/listAuthors.php tests/phpunit/tests/user/listAuthors.php
    index 11432ac..86f1a3b 100644
    class Tests_User_ListAuthors extends WP_UnitTestCase { 
    7171        }
    7272
    7373        function test_wp_list_authors_exclude_admin() {
    74                 self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) );
     74                self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) );
    7575                $expected['exclude_admin'] = '<li><a href="' . get_author_posts_url( 1 ) . '" title="Posts by admin">admin</a></li><li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
    7676                $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) );
    7777        }
  • tests/phpunit/tests/user/mapMetaCap.php

    diff --git tests/phpunit/tests/user/mapMetaCap.php tests/phpunit/tests/user/mapMetaCap.php
    index 4a65003..1b86dd1 100644
    class Tests_User_MapMetaCap extends WP_UnitTestCase { 
    1212
    1313                $this->user_ids = array();
    1414
    15                 $this->user_id   = self::$factory->user->create( array( 'role' => 'administrator' ) );
    16                 $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     15                $this->user_id   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     16                $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    1717
    1818                if ( isset( $GLOBALS['super_admins'] ) )
    1919                        $this->super_admins = $GLOBALS['super_admins'];
    class Tests_User_MapMetaCap extends WP_UnitTestCase { 
    248248         * @ticket 27020
    249249         */
    250250        function test_authorless_posts_capabilties() {
    251                 $post_id = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) );
    252                 $editor = self::$factory->user->create( array( 'role' => 'editor' ) );
     251                $post_id = self::factory()->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) );
     252                $editor = self::factory()->user->create( array( 'role' => 'editor' ) );
    253253
    254254                $this->assertEquals( array( 'edit_others_posts', 'edit_published_posts' ), map_meta_cap( 'edit_post', $editor, $post_id ) );
    255255                $this->assertEquals( array( 'delete_others_posts', 'delete_published_posts' ), map_meta_cap( 'delete_post', $editor, $post_id ) );
  • tests/phpunit/tests/user/multisite.php

    diff --git tests/phpunit/tests/user/multisite.php tests/phpunit/tests/user/multisite.php
    index 2a36d36..2e970b1 100644
    class Tests_Multisite_User extends WP_UnitTestCase { 
    2525        }
    2626
    2727        function test_remove_user_from_blog() {
    28                 $user1 = self::$factory->user->create_and_get();
    29                 $user2 = self::$factory->user->create_and_get();
     28                $user1 = self::factory()->user->create_and_get();
     29                $user2 = self::factory()->user->create_and_get();
    3030
    31                 $post_id = self::$factory->post->create( array( 'post_author' => $user1->ID ) );
     31                $post_id = self::factory()->post->create( array( 'post_author' => $user1->ID ) );
    3232
    3333                remove_user_from_blog( $user1->ID, 1, $user2->ID );
    3434
    class Tests_Multisite_User extends WP_UnitTestCase { 
    4242         * Test the returned data from get_blogs_of_user()
    4343         */
    4444        function test_get_blogs_of_user() {
    45                 $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     45                $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    4646
    4747                // Maintain a list of 6 total sites and include the primary network site.
    48                 $blog_ids = self::$factory->blog->create_many( 5, array( 'user_id' => $user1_id ) );
     48                $blog_ids = self::factory()->blog->create_many( 5, array( 'user_id' => $user1_id ) );
    4949                $blog_ids = array_merge( array( 1 ), $blog_ids );
    5050
    5151                // All sites are new and not marked as spam, archived, or deleted.
    class Tests_Multisite_User extends WP_UnitTestCase { 
    114114        function test_is_blog_user() {
    115115                global $wpdb;
    116116
    117                 $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     117                $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    118118
    119119                $old_current = get_current_user_id();
    120120                wp_set_current_user( $user1_id );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    124124
    125125                $blog_ids = array();
    126126
    127                 $blog_ids = self::$factory->blog->create_many( 5 );
     127                $blog_ids = self::factory()->blog->create_many( 5 );
    128128                foreach ( $blog_ids as $blog_id ) {
    129129                        $this->assertInternalType( 'int', $blog_id );
    130130                        $this->assertTrue( is_blog_user( $blog_id ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    138138        function test_is_user_member_of_blog() {
    139139                global $wpdb;
    140140
    141                 $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
    142                 $user2_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     141                $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
     142                $user2_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    143143
    144144                $old_current = get_current_user_id();
    145145
    class Tests_Multisite_User extends WP_UnitTestCase { 
    156156                $this->assertTrue( is_user_member_of_blog( $user1_id ) );
    157157                $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
    158158
    159                 $blog_ids = self::$factory->blog->create_many( 5 );
     159                $blog_ids = self::factory()->blog->create_many( 5 );
    160160                foreach ( $blog_ids as $blog_id ) {
    161161                        $this->assertInternalType( 'int', $blog_id );
    162162
    class Tests_Multisite_User extends WP_UnitTestCase { 
    197197         * @ticket 23192
    198198         */
    199199        function test_is_user_spammy() {
    200                 $user_id = self::$factory->user->create( array(
     200                $user_id = self::factory()->user->create( array(
    201201                        'role' => 'author',
    202202                        'user_login' => 'testuser1',
    203203                ) );
    204204
    205205                $spam_username = (string) $user_id;
    206                 $spam_user_id = self::$factory->user->create( array(
     206                $spam_user_id = self::factory()->user->create( array(
    207207                        'role' => 'author',
    208208                        'user_login' => $spam_username,
    209209                ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    219219        function test_user_member_of_blog() {
    220220                global $wp_rewrite;
    221221
    222                 self::$factory->blog->create();
    223                 $user_id = self::$factory->user->create();
    224                 self::$factory->blog->create( array( 'user_id' => $user_id ) );
     222                self::factory()->blog->create();
     223                $user_id = self::factory()->user->create();
     224                self::factory()->blog->create( array( 'user_id' => $user_id ) );
    225225
    226226                $blogs = get_blogs_of_user( $user_id );
    227227                $this->assertCount( 2, $blogs );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    261261                        unset( $GLOBALS['super_admins'] );
    262262                }
    263263
    264                 $user_id = self::$factory->user->create();
     264                $user_id = self::factory()->user->create();
    265265                grant_super_admin( $user_id );
    266266                revoke_super_admin( $user_id );
    267267
    class Tests_Multisite_User extends WP_UnitTestCase { 
    278278                        unset( $GLOBALS['super_admins'] );
    279279                }
    280280
    281                 $user_id = self::$factory->user->create();
     281                $user_id = self::factory()->user->create();
    282282                grant_super_admin( $user_id );
    283283                revoke_super_admin( $user_id );
    284284                wpmu_delete_user( $user_id );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    297297                        unset( $GLOBALS['super_admins'] );
    298298                }
    299299
    300                 $user_id = self::$factory->user->create();
     300                $user_id = self::factory()->user->create();
    301301                grant_super_admin( $user_id );
    302302
    303303                $this->assertFalse( wpmu_delete_user( $user_id ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    316316                        unset( $GLOBALS['super_admins'] );
    317317                }
    318318
    319                 $user_id = self::$factory->user->create();
     319                $user_id = self::factory()->user->create();
    320320
    321321                $this->assertFalse( is_super_admin( $user_id ) );
    322322                $this->assertFalse( revoke_super_admin( $user_id ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    329329                $this->assertFalse( isset( $GLOBALS['super_admins'] ) );
    330330
    331331                // Try with two users.
    332                 $second_user = self::$factory->user->create();
     332                $second_user = self::factory()->user->create();
    333333                $this->assertTrue( grant_super_admin( $user_id ) );
    334334                $this->assertTrue( grant_super_admin( $second_user ) );
    335335                $this->assertTrue( is_super_admin( $second_user ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    343343        }
    344344
    345345        public function test_numeric_string_user_id() {
    346                 $u = self::$factory->user->create();
     346                $u = self::factory()->user->create();
    347347
    348348                $u_string = (string) $u;
    349349                $this->assertTrue( wpmu_delete_user( $u_string ) );
    class Tests_Multisite_User extends WP_UnitTestCase { 
    361361         * @ticket 33800
    362362         */
    363363        public function test_should_return_false_for_object_user_id() {
    364                 $u_obj = self::$factory->user->create_and_get();
     364                $u_obj = self::factory()->user->create_and_get();
    365365                $this->assertFalse( wpmu_delete_user( $u_obj ) );
    366366                $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) );
    367367        }
  • tests/phpunit/tests/user/query.php

    diff --git tests/phpunit/tests/user/query.php tests/phpunit/tests/user/query.php
    index 0287975..a354bed 100644
    class Tests_User_Query extends WP_UnitTestCase { 
    245245         * @ticket 31265
    246246         */
    247247        public function test_orderby_clause_key_as_secondary_sort() {
    248                 $u1 = self::$factory->user->create( array(
     248                $u1 = self::factory()->user->create( array(
    249249                        'user_registered' => '2015-01-28 03:00:00',
    250250                ) );
    251                 $u2 = self::$factory->user->create( array(
     251                $u2 = self::factory()->user->create( array(
    252252                        'user_registered' => '2015-01-28 05:00:00',
    253253                ) );
    254                 $u3 = self::$factory->user->create( array(
     254                $u3 = self::factory()->user->create( array(
    255255                        'user_registered' => '2015-01-28 03:00:00',
    256256                ) );
    257257
    class Tests_User_Query extends WP_UnitTestCase { 
    598598                        $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    599599                }
    600600
    601                 $b = self::$factory->blog->create();
     601                $b = self::factory()->blog->create();
    602602
    603603                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    604604
    class Tests_User_Query extends WP_UnitTestCase { 
    624624                        $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    625625                }
    626626
    627                 $b = self::$factory->blog->create();
     627                $b = self::factory()->blog->create();
    628628                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    629629
    630630                $query = new WP_User_Query( array(
    class Tests_User_Query extends WP_UnitTestCase { 
    649649                        $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    650650                }
    651651
    652                 $b = self::$factory->blog->create();
     652                $b = self::factory()->blog->create();
    653653
    654654                add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
    655655                add_user_to_blog( $b, self::$author_ids[1], 'author' );
    class Tests_User_Query extends WP_UnitTestCase { 
    675675                        $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    676676                }
    677677
    678                 $b = self::$factory->blog->create();
     678                $b = self::factory()->blog->create();
    679679
    680680                add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
    681681                add_user_to_blog( $b, self::$author_ids[1], 'author' );
    class Tests_User_Query extends WP_UnitTestCase { 
    707707                register_post_type( 'wptests_pt_public', array( 'public' => true ) );
    708708                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    709709
    710                 self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    711                 self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
     710                self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
     711                self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    712712
    713713                $q = new WP_User_Query( array(
    714714                        'has_published_posts' => true,
    class Tests_User_Query extends WP_UnitTestCase { 
    727727                register_post_type( 'wptests_pt_public', array( 'public' => true ) );
    728728                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    729729
    730                 self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
    731                 self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
    732                 self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
     730                self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) );
     731                self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) );
     732                self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    733733
    734734                $q = new WP_User_Query( array(
    735735                        'has_published_posts' => array( 'wptests_pt_private', 'post' ),
    class Tests_User_Query extends WP_UnitTestCase { 
    748748                register_post_type( 'wptests_pt_public', array( 'public' => true ) );
    749749                register_post_type( 'wptests_pt_private', array( 'public' => false ) );
    750750
    751                 self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) );
    752                 self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) );
    753                 self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
     751                self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) );
     752                self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) );
     753                self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) );
    754754
    755755                $q = new WP_User_Query( array(
    756756                        'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ),
    class Tests_User_Query extends WP_UnitTestCase { 
    770770                        $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    771771                }
    772772
    773                 $blogs = self::$factory->blog->create_many( 2 );
     773                $blogs = self::factory()->blog->create_many( 2 );
    774774
    775775                add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' );
    776776                add_user_to_blog( $blogs[0], self::$author_ids[1], 'author' );
    class Tests_User_Query extends WP_UnitTestCase { 
    778778                add_user_to_blog( $blogs[1], self::$author_ids[1], 'author' );
    779779
    780780                switch_to_blog( $blogs[0] );
    781                 self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) );
     781                self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) );
    782782                restore_current_blog();
    783783
    784784                switch_to_blog( $blogs[1] );
    785                 self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) );
     785                self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) );
    786786                restore_current_blog();
    787787
    788788                $q = new WP_User_Query( array(
    class Tests_User_Query extends WP_UnitTestCase { 
    931931         * @ticket 22212
    932932         */
    933933        public function test_get_single_role_by_string_which_is_similar() {
    934                 $another_editor = self::$factory->user->create( array(
     934                $another_editor = self::factory()->user->create( array(
    935935                        'role' => 'another-editor',
    936936                ) );
    937937
    class Tests_User_Query extends WP_UnitTestCase { 
    11481148                        $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    11491149                }
    11501150
    1151                 $sites = self::$factory->blog->create_many( 2 );
     1151                $sites = self::factory()->blog->create_many( 2 );
    11521152
    11531153                add_user_to_blog( $sites[0], self::$author_ids[0], 'author' );
    11541154                add_user_to_blog( $sites[1], self::$author_ids[1], 'author' );
  • tests/phpunit/tests/user/session.php

    diff --git tests/phpunit/tests/user/session.php tests/phpunit/tests/user/session.php
    index ee29cce..c3f9638 100644
    class Tests_User_Session extends WP_UnitTestCase { 
    1010        function setUp() {
    1111                parent::setUp();
    1212                remove_all_filters( 'session_token_manager' );
    13                 $user_id = self::$factory->user->create();
     13                $user_id = self::factory()->user->create();
    1414                $this->manager = WP_Session_Tokens::get_instance( $user_id );
    1515                $this->assertInstanceOf( 'WP_Session_Tokens', $this->manager );
    1616                $this->assertInstanceOf( 'WP_User_Meta_Session_Tokens', $this->manager );
  • tests/phpunit/tests/user/slashes.php

    diff --git tests/phpunit/tests/user/slashes.php tests/phpunit/tests/user/slashes.php
    index 9b44484..54dbf78 100644
     
    88class Tests_User_Slashes extends WP_UnitTestCase {
    99        function setUp() {
    1010                parent::setUp();
    11                 $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) );
     11                $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    1212                $this->old_current_user = get_current_user_id();
    1313                wp_set_current_user( $this->author_id );
    1414
    class Tests_User_Slashes extends WP_UnitTestCase { 
    8383         *
    8484         */
    8585        function test_edit_user() {
    86                 $id = self::$factory->user->create();
     86                $id = self::factory()->user->create();
    8787
    8888                $_POST = $_GET = $_REQUEST = array();
    8989                $_POST['role'] = 'subscriber';
    class Tests_User_Slashes extends WP_UnitTestCase { 
    173173         *
    174174         */
    175175        function test_wp_update_user() {
    176                 $id = self::$factory->user->create();
     176                $id = self::factory()->user->create();
    177177                $id = wp_update_user(array(
    178178                        'ID' => $id,
    179179                        'role' => 'subscriber',
  • tests/phpunit/tests/user/updateUserCaches.php

    diff --git tests/phpunit/tests/user/updateUserCaches.php tests/phpunit/tests/user/updateUserCaches.php
    index 7d29cec..9be0717 100644
    class Tests_User_UpdateUserCaches extends WP_UnitTestCase { 
    77        public function test_should_store_entire_database_row_in_users_bucket() {
    88                global $wpdb;
    99
    10                 $u = self::$factory->user->create();
     10                $u = self::factory()->user->create();
    1111                $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) );
    1212
    1313                update_user_caches( $raw_userdata );
    class Tests_User_UpdateUserCaches extends WP_UnitTestCase { 
    5757        public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object() {
    5858                global $wpdb;
    5959
    60                 $u = self::$factory->user->create();
     60                $u = self::factory()->user->create();
    6161                $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) );
    6262                $user_object = new WP_User( $u );
    6363
  • tests/phpunit/tests/user/wpDeleteUser.php

    diff --git tests/phpunit/tests/user/wpDeleteUser.php tests/phpunit/tests/user/wpDeleteUser.php
    index 6c05a2a..20d54c9 100644
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    1414                // Logged out users don't have blogs.
    1515                $this->assertEquals( array(), get_blogs_of_user( 0 ) );
    1616
    17                 $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) );
     17                $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    1818                $blogs = get_blogs_of_user( $user_id );
    1919                $this->assertEquals( array( 1 ), array_keys( $blogs ) );
    2020
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    3434        function test_is_user_member_of_blog() {
    3535                $old_current = get_current_user_id();
    3636
    37                 $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) );
     37                $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
    3838                wp_set_current_user( $user_id );
    3939
    4040                $this->assertTrue( is_user_member_of_blog() );
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    5454        }
    5555
    5656        function test_delete_user() {
    57                 $user_id = self::$factory->user->create( array( 'role' => 'author' ) );
     57                $user_id = self::factory()->user->create( array( 'role' => 'author' ) );
    5858                $user = new WP_User( $user_id );
    5959
    6060                $post = array(
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    111111         * @ticket 20447
    112112         */
    113113        function test_wp_delete_user_reassignment_clears_post_caches() {
    114                 $user_id   = self::$factory->user->create();
    115                 $reassign  = self::$factory->user->create();
    116                 $post_id   = self::$factory->post->create( array( 'post_author' => $user_id ) );
     114                $user_id   = self::factory()->user->create();
     115                $reassign  = self::factory()->user->create();
     116                $post_id   = self::factory()->post->create( array( 'post_author' => $user_id ) );
    117117
    118118                get_post( $post_id ); // Ensure this post is in the cache.
    119119
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    128128                        $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' );
    129129                }
    130130
    131                 $u = self::$factory->user->create();
     131                $u = self::factory()->user->create();
    132132
    133133                $u_string = (string) $u;
    134134                $this->assertTrue( wp_delete_user( $u_string ) );
    class Tests_User_WpDeleteUser extends WP_UnitTestCase { 
    150150                        $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' );
    151151                }
    152152
    153                 $u_obj = self::$factory->user->create_and_get();
     153                $u_obj = self::factory()->user->create_and_get();
    154154                $this->assertFalse( wp_delete_user( $u_obj ) );
    155155                $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) );
    156156        }
  • tests/phpunit/tests/user/wpGetUsersWithNoRole.php

    diff --git tests/phpunit/tests/user/wpGetUsersWithNoRole.php tests/phpunit/tests/user/wpGetUsersWithNoRole.php
    index d9cc898..6eb6823 100644
    class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { 
    1515                }
    1616
    1717                // Setup users
    18                 $admin = self::$factory->user->create( array(
     18                $admin = self::factory()->user->create( array(
    1919                        'role' => 'administrator',
    2020                ) );
    21                 $editor = self::$factory->user->create( array(
     21                $editor = self::factory()->user->create( array(
    2222                        'role' => 'editor',
    2323                ) );
    24                 $nobody = self::$factory->user->create( array(
     24                $nobody = self::factory()->user->create( array(
    2525                        'role' => '',
    2626                ) );
    27                 $nobody_else = self::$factory->user->create( array(
     27                $nobody_else = self::factory()->user->create( array(
    2828                        'role' => '',
    2929                ) );
    3030
    class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { 
    4949                }
    5050
    5151                // Setup users
    52                 $admin = self::$factory->user->create( array(
     52                $admin = self::factory()->user->create( array(
    5353                        'role' => 'administrator',
    5454                ) );
    55                 $editor = self::$factory->user->create( array(
     55                $editor = self::factory()->user->create( array(
    5656                        'role' => 'editor',
    5757                ) );
    58                 $nobody = self::$factory->user->create( array(
     58                $nobody = self::factory()->user->create( array(
    5959                        'role' => '',
    6060                ) );
    6161
    6262                // Setup blogs
    63                 $blog_1 = (int) self::$factory->blog->create( array(
     63                $blog_1 = (int) self::factory()->blog->create( array(
    6464                        'user_id' => $editor,
    6565                ) );
    6666
  • tests/phpunit/tests/user/wpSetCurrentUser.php

    diff --git tests/phpunit/tests/user/wpSetCurrentUser.php tests/phpunit/tests/user/wpSetCurrentUser.php
    index 5b7c0f0..212041c 100644
     
    55 */
    66class Tests_User_WpSetCurrentUser extends WP_UnitTestCase {
    77        public function test_set_by_id() {
    8                 $u = self::$factory->user->create();
     8                $u = self::factory()->user->create();
    99
    1010                $user = wp_set_current_user( $u );
    1111
    class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { 
    1515        }
    1616
    1717        public function test_name_should_be_ignored_if_id_is_not_null() {
    18                 $u = self::$factory->user->create();
     18                $u = self::factory()->user->create();
    1919
    2020                $user = wp_set_current_user( $u, 'foo' );
    2121
    class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { 
    2525        }
    2626
    2727        public function test_should_set_by_name_if_id_is_null_and_current_user_is_nonempty() {
    28                 $u1 = self::$factory->user->create();
     28                $u1 = self::factory()->user->create();
    2929                wp_set_current_user( $u1 );
    3030                $this->assertSame( $u1, get_current_user_id() );
    3131
    32                 $u2 = self::$factory->user->create( array(
     32                $u2 = self::factory()->user->create( array(
    3333                        'user_login' => 'foo',
    3434                ) );
    3535
    class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { 
    4949                wp_set_current_user( 0 );
    5050                $this->assertSame( 0, get_current_user_id() );
    5151
    52                 $u = self::$factory->user->create( array(
     52                $u = self::factory()->user->create( array(
    5353                        'user_login' => 'foo',
    5454                ) );
    5555
  • tests/phpunit/tests/widgets.php

    diff --git tests/phpunit/tests/widgets.php tests/phpunit/tests/widgets.php
    index 35cadc4..7b64efb 100644
    class Tests_Widgets extends WP_UnitTestCase { 
    438438                $this->assertEmpty( $wp_customize );
    439439                $this->assertFalse( $widget->is_preview() );
    440440
    441                 wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) );
     441                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    442442                require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    443443                $wp_customize = new WP_Customize_Manager();
    444444                $wp_customize->start_previewing_theme();
  • tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php

    diff --git tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php
    index ef23c7b..8d9c027 100644
    class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { 
    2222        function test_no_editable_posts() {
    2323                $this->make_user_by_role( 'author' );
    2424                $editor = $this->make_user_by_role( 'editor' );
    25                 self::$factory->post->create( array( 'post_author' => $editor ) );
     25                self::factory()->post->create( array( 'post_author' => $editor ) );
    2626
    2727                $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    2828                $this->assertNotInstanceOf( 'IXR_Error', $result );
    class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { 
    3232        function test_date() {
    3333                $this->make_user_by_role( 'author' );
    3434
    35                 self::$factory->post->create();
     35                self::factory()->post->create();
    3636
    3737                $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    3838                $this->assertNotInstanceOf( 'IXR_Error', $results );
  • tests/phpunit/tests/xmlrpc/mw/editPost.php

    diff --git tests/phpunit/tests/xmlrpc/mw/editPost.php tests/phpunit/tests/xmlrpc/mw/editPost.php
    index 982ab23..fbdf20e 100644
    class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { 
    126126
    127127                // create attachment
    128128                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    129                 $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     129                $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    130130
    131131                // add post thumbnail to post that does not have one
    132132                $post2 = array( 'wp_post_thumbnail' => $attachment_id );
    class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { 
    141141                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    142142
    143143                // create another attachment
    144                 $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     144                $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    145145
    146146                // change the post's post_thumbnail
    147147                $post4 = array( 'wp_post_thumbnail' => $attachment2_id );
    class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { 
    228228
    229229                $editor_id = $this->make_user_by_role( 'editor' );
    230230
    231                 $post_id = self::$factory->post->create( array(
     231                $post_id = self::factory()->post->create( array(
    232232                        'post_author' => $editor_id
    233233                ) );
    234234
    class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { 
    251251        function test_empty_not_null() {
    252252                $editor_id = $this->make_user_by_role( 'editor' );
    253253
    254                 $post_id = self::$factory->post->create( array(
     254                $post_id = self::factory()->post->create( array(
    255255                        'post_title' => 'Title',
    256256                        'post_author' => $editor_id,
    257257                        'tags_input' => 'taco'
  • tests/phpunit/tests/xmlrpc/mw/getPost.php

    diff --git tests/phpunit/tests/xmlrpc/mw/getPost.php tests/phpunit/tests/xmlrpc/mw/getPost.php
    index e8d77b7..9ae05e7 100644
    class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { 
    9595
    9696                // create attachment
    9797                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    98                 $attachment_id = self::$factory->attachment->create_upload_object( $filename );
     98                $attachment_id = self::factory()->attachment->create_upload_object( $filename );
    9999
    100100                set_post_thumbnail( $this->post_id, $attachment_id );
    101101
  • tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php

    diff --git tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
    index 641fb03..ac5e021 100644
    class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { 
    100100
    101101                // create attachment
    102102                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    103                 $attachment_id = self::$factory->attachment->create_upload_object( $filename, $this->post_id );
     103                $attachment_id = self::factory()->attachment->create_upload_object( $filename, $this->post_id );
    104104                set_post_thumbnail( $this->post_id, $attachment_id );
    105105
    106106                $results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) );
  • tests/phpunit/tests/xmlrpc/mw/newPost.php

    diff --git tests/phpunit/tests/xmlrpc/mw/newPost.php tests/phpunit/tests/xmlrpc/mw/newPost.php
    index e780479..c849f65 100644
    class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { 
    117117
    118118                // create attachment
    119119                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    120                 $attachment_id = self::$factory->attachment->create_upload_object( $filename );
     120                $attachment_id = self::factory()->attachment->create_upload_object( $filename );
    121121
    122122                $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id );
    123123                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
  • tests/phpunit/tests/xmlrpc/wp/deletePost.php

    diff --git tests/phpunit/tests/xmlrpc/wp/deletePost.php tests/phpunit/tests/xmlrpc/wp/deletePost.php
    index 93c3390..e7284a7 100644
    class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { 
    2121
    2222        function test_incapable_user() {
    2323                $this->make_user_by_role( 'subscriber' );
    24                 $post_id = self::$factory->post->create();
     24                $post_id = self::factory()->post->create();
    2525
    2626                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) );
    2727                $this->assertInstanceOf( 'IXR_Error', $result );
    class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { 
    3030
    3131        function test_post_deleted() {
    3232                $this->make_user_by_role( 'editor' );
    33                 $post_id = self::$factory->post->create();
     33                $post_id = self::factory()->post->create();
    3434
    3535                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) );
    3636                $this->assertNotInstanceOf( 'IXR_Error', $result );
  • tests/phpunit/tests/xmlrpc/wp/editComment.php

    diff --git tests/phpunit/tests/xmlrpc/wp/editComment.php tests/phpunit/tests/xmlrpc/wp/editComment.php
    index 9e7c1f9..c885957 100644
    class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_author_can_edit_own_comment() {
    99                $author_id = $this->make_user_by_role( 'author' );
    10                 $post_id = self::$factory->post->create( array(
     10                $post_id = self::factory()->post->create( array(
    1111                        'post_title' => 'Post test by author',
    1212                        'post_author' => $author_id
    1313                ) );
    class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { 
    2929        function test_author_cannot_edit_others_comment() {
    3030                $this->make_user_by_role( 'author' );
    3131                $editor_id = $this->make_user_by_role( 'editor' );
    32                 $post_id = self::$factory->post->create( array(
     32                $post_id = self::factory()->post->create( array(
    3333                        'post_title' => 'Post test by editor',
    3434                        'post_author' => $editor_id
    3535                ) );
    class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { 
    4949
    5050        function test_trash_comment() {
    5151                $this->make_user_by_role( 'administrator' );
    52                 $post_id = self::$factory->post->create();
     52                $post_id = self::factory()->post->create();
    5353
    5454                $comment_data = array(
    5555                        'comment_post_ID' => $post_id,
    class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { 
    7878                update_option( 'timezone_string', 'America/New_York' );
    7979
    8080                $this->make_user_by_role( 'administrator' );
    81                 $post_id = self::$factory->post->create();
     81                $post_id = self::factory()->post->create();
    8282
    8383                $comment_data = array(
    8484                        'comment_post_ID' => $post_id,
  • tests/phpunit/tests/xmlrpc/wp/editPost.php

    diff --git tests/phpunit/tests/xmlrpc/wp/editPost.php tests/phpunit/tests/xmlrpc/wp/editPost.php
    index 299f3a4..20ba377 100644
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    126126
    127127                // create attachment
    128128                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    129                 $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     129                $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    130130
    131131                // add post thumbnail to post that does not have one
    132132                $post2 = array( 'post_thumbnail' => $attachment_id );
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    148148                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    149149
    150150                // create another attachment
    151                 $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     151                $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    152152
    153153                // change the post's post_thumbnail
    154154                $post4 = array( 'post_thumbnail' => $attachment2_id );
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    208208        function test_capable_unsticky() {
    209209                $editor_id = $this->make_user_by_role( 'editor' );
    210210
    211                 $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
     211                $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) );
    212212                stick_post( $post_id );
    213213
    214214                $post2 = array( 'sticky' => false );
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    220220        function test_password_transition_unsticky() {
    221221                // when transitioning to private status or adding a post password, post should be un-stuck
    222222                $editor_id = $this->make_user_by_role( 'editor' );
    223                 $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
     223                $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) );
    224224                stick_post( $post_id );
    225225
    226226                $post2 = array( 'post_password' => 'foobar',  'sticky' => false );
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    234234
    235235                $yesterday = strtotime( '-1 day' );
    236236
    237                 $post_id = self::$factory->post->create( array(
     237                $post_id = self::factory()->post->create( array(
    238238                        'post_title'   => 'Post Revision Test',
    239239                        'post_content' => 'Not edited',
    240240                        'post_author'  => $editor_id,
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    263263        function test_edit_attachment() {
    264264                $editor_id = $this->make_user_by_role( 'editor' );
    265265
    266                 $post_id = self::$factory->post->create( array(
     266                $post_id = self::factory()->post->create( array(
    267267                        'post_title'   => 'Post Revision Test',
    268268                        'post_content' => 'Not edited',
    269269                        'post_status'  => 'inherit',
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    282282        function test_use_invalid_post_status() {
    283283                $editor_id = $this->make_user_by_role( 'editor' );
    284284
    285                 $post_id = self::$factory->post->create( array(
     285                $post_id = self::factory()->post->create( array(
    286286                        'post_title'   => 'Post Revision Test',
    287287                        'post_content' => 'Not edited',
    288288                        'post_author'  => $editor_id,
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    302302        function test_loss_of_categories_on_edit() {
    303303                $editor_id = $this->make_user_by_role( 'editor' );
    304304
    305                 $post_id = self::$factory->post->create( array( 'post_author'  => $editor_id ) );
    306                 $term_id = self::$factory->category->create();
    307                 self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
     305                $post_id = self::factory()->post->create( array( 'post_author'  => $editor_id ) );
     306                $term_id = self::factory()->category->create();
     307                self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true );
    308308                $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
    309309                $this->assertContains( $term_id, $term_ids );
    310310
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    322322        function test_clear_categories_on_edit() {
    323323                $editor_id = $this->make_user_by_role( 'editor' );
    324324
    325                 $post_id = self::$factory->post->create( array( 'post_author'  => $editor_id ) );
    326                 $term_id = self::$factory->category->create();
    327                 self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
     325                $post_id = self::factory()->post->create( array( 'post_author'  => $editor_id ) );
     326                $term_id = self::factory()->category->create();
     327                self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true );
    328328                $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
    329329                $this->assertContains( $term_id, $term_ids );
    330330
    class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    365365                $editor_id = $this->make_user_by_role( 'editor' );
    366366
    367367                // Add a dummy post
    368                 $post_id = self::$factory->post->create( array(
     368                $post_id = self::factory()->post->create( array(
    369369                        'post_title'   => 'Post Enclosure Test',
    370370                        'post_content' => 'Fake content',
    371371                        'post_author'  => $editor_id,
  • tests/phpunit/tests/xmlrpc/wp/getComment.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getComment.php tests/phpunit/tests/xmlrpc/wp/getComment.php
    index f80d357..1e6bda1 100644
    class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { 
    1313        function setUp() {
    1414                parent::setUp();
    1515
    16                 $this->post_id = self::$factory->post->create();
     16                $this->post_id = self::factory()->post->create();
    1717
    1818                $this->parent_comment_data = array(
    1919                        'comment_post_ID' => $this->post_id,
  • tests/phpunit/tests/xmlrpc/wp/getComments.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getComments.php tests/phpunit/tests/xmlrpc/wp/getComments.php
    index 261bf95..a4bdf22 100644
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    2121        }
    2222
    2323        function test_capable_user() {
    24                 $this->post_id = self::$factory->post->create();
    25                 self::$factory->comment->create_post_comments( $this->post_id, 2 );
     24                $this->post_id = self::factory()->post->create();
     25                self::factory()->comment->create_post_comments( $this->post_id, 2 );
    2626
    2727                $this->make_user_by_role( 'editor' );
    2828
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    3636        }
    3737
    3838        function test_post_filter() {
    39                 $this->post_id = self::$factory->post->create();
    40                 self::$factory->comment->create_post_comments( $this->post_id, 2 );
     39                $this->post_id = self::factory()->post->create();
     40                self::factory()->comment->create_post_comments( $this->post_id, 2 );
    4141
    4242                $this->make_user_by_role( 'editor' );
    4343
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    5252        }
    5353
    5454        function test_number_filter() {
    55                 $this->post_id = self::$factory->post->create();
    56                 self::$factory->comment->create_post_comments( $this->post_id, 11 );
     55                $this->post_id = self::factory()->post->create();
     56                self::factory()->comment->create_post_comments( $this->post_id, 11 );
    5757
    5858                $this->make_user_by_role( 'editor' );
    5959
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    7676        function test_contributor_capabilities() {
    7777                $this->make_user_by_role( 'contributor' );
    7878                $author_id = $this->make_user_by_role( 'author' );
    79                 $author_post_id = self::$factory->post->create( array(
     79                $author_post_id = self::factory()->post->create( array(
    8080                        'post_title' => 'Author',
    8181                        'post_author' => $author_id,
    8282                        'post_status' => 'publish'
    8383                ) );
    8484
    85                 self::$factory->comment->create( array(
     85                self::factory()->comment->create( array(
    8686                        'comment_post_ID' => $author_post_id,
    8787                        'comment_author' => "Commenter 1",
    8888                        'comment_author_url' => "http://example.com/1/",
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    9090                ) );
    9191
    9292                $editor_id = $this->make_user_by_role( 'editor' );
    93                 $editor_post_id = self::$factory->post->create( array(
     93                $editor_post_id = self::factory()->post->create( array(
    9494                        'post_title' => 'Editor',
    9595                        'post_author' => $editor_id,
    9696                        'post_status' => 'publish'
    9797                ) );
    9898
    99                 self::$factory->comment->create( array(
     99                self::factory()->comment->create( array(
    100100                        'comment_post_ID' => $editor_post_id,
    101101                        'comment_author' => 'Commenter 2',
    102102                        'comment_author_url' => 'http://example.com/2/',
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    110110
    111111        function test_author_capabilities() {
    112112                $author_id = $this->make_user_by_role( 'author' );
    113                 $author_post_id = self::$factory->post->create( array(
     113                $author_post_id = self::factory()->post->create( array(
    114114                        'post_title' => 'Author',
    115115                        'post_author' => $author_id,
    116116                        'post_status' => 'publish'
    117117                ) );
    118118
    119                 self::$factory->comment->create( array(
     119                self::factory()->comment->create( array(
    120120                        'comment_post_ID' => $author_post_id,
    121121                        'comment_author' => 'Commenter 1',
    122122                        'comment_author_url' => 'http://example.com/1/',
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    124124                ) );
    125125
    126126                $editor_id = $this->make_user_by_role( 'editor' );
    127                 $editor_post_id = self::$factory->post->create( array(
     127                $editor_post_id = self::factory()->post->create( array(
    128128                        'post_title' => 'Editor',
    129129                        'post_author' => $editor_id,
    130130                        'post_status' => 'publish'
    131131                ) );
    132132
    133                 self::$factory->comment->create( array(
     133                self::factory()->comment->create( array(
    134134                        'comment_post_ID' => $editor_post_id,
    135135                        'comment_author' => 'Commenter 2',
    136136                        'comment_author_url' => 'http://example.com/2/',
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    166166
    167167        function test_editor_capabilities() {
    168168                $author_id = $this->make_user_by_role( 'author' );
    169                 $author_post_id = self::$factory->post->create( array(
     169                $author_post_id = self::factory()->post->create( array(
    170170                        'post_title' => 'Author',
    171171                        'post_author' => $author_id,
    172172                        'post_status' => 'publish'
    173173                ) );
    174174
    175                 self::$factory->comment->create( array(
     175                self::factory()->comment->create( array(
    176176                        'comment_post_ID' => $author_post_id,
    177177                        'comment_author' => 'Commenter 1',
    178178                        'comment_author_url' => 'http://example.com/1/',
    class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    180180                ));
    181181
    182182                $editor_id = $this->make_user_by_role( 'editor' );
    183                 $editor_post_id = self::$factory->post->create( array(
     183                $editor_post_id = self::factory()->post->create( array(
    184184                        'post_title' => 'Editor',
    185185                        'post_author' => $editor_id,
    186186                        'post_status' => 'publish'
    187187                ) );
    188188
    189                 self::$factory->comment->create(array(
     189                self::factory()->comment->create(array(
    190190                        'comment_post_ID' => $editor_post_id,
    191191                        'comment_author' => 'Commenter 2',
    192192                        'comment_author_url' => 'http://example.com/2/',
  • tests/phpunit/tests/xmlrpc/wp/getPost.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getPost.php tests/phpunit/tests/xmlrpc/wp/getPost.php
    index 345a8a7..6e6ecae 100644
    class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { 
    122122        function test_valid_page() {
    123123                $this->make_user_by_role( 'editor' );
    124124
    125                 $parent_page_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
    126                 $child_page_id = self::$factory->post->create( array(
     125                $parent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     126                $child_page_id = self::factory()->post->create( array(
    127127                        'post_type' => 'page',
    128128                        'post_parent' => $parent_page_id,
    129129                        'menu_order' => 2
  • tests/phpunit/tests/xmlrpc/wp/getPosts.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getPosts.php tests/phpunit/tests/xmlrpc/wp/getPosts.php
    index 62bac31..3d8dff4 100644
    class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { 
    5454                $post_ids = array();
    5555                $num_posts = 4;
    5656                foreach ( range( 1, $num_posts ) as $i ) {
    57                         $post_ids[] = self::$factory->post->create( array(
     57                        $post_ids[] = self::factory()->post->create( array(
    5858                                'post_type' => $cpt_name,
    5959                                'post_date' => date( 'Y-m-d H:i:s', time() + $i )
    6060                        ) );
    class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { 
    8080                // add comments to some of the posts
    8181                foreach ( $post_ids as $key => $post_id ) {
    8282                        // Larger post IDs will get more comments.
    83                         self::$factory->comment->create_post_comments( $post_id, $key );
     83                        self::factory()->comment->create_post_comments( $post_id, $key );
    8484                }
    8585
    8686                // get results ordered by comment count
    class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { 
    109109
    110110        function test_fields() {
    111111                $this->make_user_by_role( 'editor' );
    112                 self::$factory->post->create();
     112                self::factory()->post->create();
    113113
    114114                // check default fields
    115115                $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
    class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { 
    136136        function test_search() {
    137137                $this->make_user_by_role( 'editor' );
    138138
    139                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) );
    140                 $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) );
     139                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: ' . rand_str() ) );
     140                $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: ' . rand_str() ) );
    141141
    142142                // Search for none of them
    143143                $filter = array( 's' => rand_str() );
  • tests/phpunit/tests/xmlrpc/wp/getRevisions.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getRevisions.php tests/phpunit/tests/xmlrpc/wp/getRevisions.php
    index 831a603..a407c65 100644
    class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { 
    1414        function test_incapable_user() {
    1515                $this->make_user_by_role( 'subscriber' );
    1616
    17                 $post_id = self::$factory->post->create();
     17                $post_id = self::factory()->post->create();
    1818
    1919                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) );
    2020                $this->assertInstanceOf( 'IXR_Error', $result );
    class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { 
    2424        function test_capable_user() {
    2525                $this->make_user_by_role( 'editor' );
    2626
    27                 $post_id = self::$factory->post->create();
     27                $post_id = self::factory()->post->create();
    2828                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
    2929                $this->assertNotInstanceOf( 'IXR_Error', $result );
    3030        }
    class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { 
    3232        function test_revision_count() {
    3333                $this->make_user_by_role( 'editor' );
    3434
    35                 $post_id = self::$factory->post->create();
     35                $post_id = self::factory()->post->create();
    3636                wp_insert_post( array( 'ID' => $post_id, 'post_content' => 'Edit 1' ) ); // Create the initial revision
    3737
    3838                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
  • tests/phpunit/tests/xmlrpc/wp/getTerms.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getTerms.php tests/phpunit/tests/xmlrpc/wp/getTerms.php
    index b8d1bdb..e6b459e 100644
    class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { 
    106106                $cat1 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
    107107                $cat2 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) );
    108108
    109                 self::$factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) );
    110                 self::$factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) );
     109                self::factory()->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) );
     110                self::factory()->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) );
    111111
    112112                $filter = array( 'orderby' => 'count', 'order' => 'DESC' );
    113113                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
  • tests/phpunit/tests/xmlrpc/wp/getUsers.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getUsers.php tests/phpunit/tests/xmlrpc/wp/getUsers.php
    index 81fc833..27a7556 100644
    class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { 
    7979                if ( is_multisite() )
    8080                        grant_super_admin( $administrator_id );
    8181
    82                 self::$factory->user->create_many( 5 );
     82                self::factory()->user->create_many( 5 );
    8383
    8484                $user_ids = get_users( array( 'fields' => 'ID' ) );
    8585
  • tests/phpunit/tests/xmlrpc/wp/newComment.php

    diff --git tests/phpunit/tests/xmlrpc/wp/newComment.php tests/phpunit/tests/xmlrpc/wp/newComment.php
    index 5ac6ae4..eb0f3b7 100644
     
    66class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase {
    77        function test_new_comment_post_closed() {
    88                $this->make_user_by_role( 'administrator' );
    9                 $post = self::$factory->post->create_and_get( array(
     9                $post = self::factory()->post->create_and_get( array(
    1010                        'comment_status' => 'closed'
    1111                ) );
    1212
  • tests/phpunit/tests/xmlrpc/wp/newPost.php

    diff --git tests/phpunit/tests/xmlrpc/wp/newPost.php tests/phpunit/tests/xmlrpc/wp/newPost.php
    index 4c881b8..3f9343f 100644
    class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { 
    128128
    129129                // create attachment
    130130                $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    131                 $attachment_id = self::$factory->attachment->create_upload_object( $filename );
     131                $attachment_id = self::factory()->attachment->create_upload_object( $filename );
    132132
    133133                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id );
    134134                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
  • tests/phpunit/tests/xmlrpc/wp/restoreRevision.php

    diff --git tests/phpunit/tests/xmlrpc/wp/restoreRevision.php tests/phpunit/tests/xmlrpc/wp/restoreRevision.php
    index f53afa7..75f5d74 100644
    class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { 
    1010        function setUp() {
    1111                parent::setUp();
    1212
    13                 $this->post_id = self::$factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision
     13                $this->post_id = self::factory()->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision
    1414                // First saved revision on update, see https://core.trac.wordpress.org/changeset/24650
    1515                wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) );
    1616