Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (11 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/conditionals.php

    r35225 r35242  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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
    … …  
    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
    … …  
    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
    … …  
    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 );
    … …  
    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/");
    … …  
    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 );
    … …  
    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 );
    … …  
    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
    … …  
    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
    … …  
    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 );
    … …  
    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
    … …  
    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) {
    … …  
    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}/");
    … …  
    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()
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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');
    … …  
    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/");
    … …  
    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
    … …  
    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',
    … …  
    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);
    … …  
    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
    … …  
    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/" );
    … …  
    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
    … …  
    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',
    … …  
    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                ) );
    … …  
    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
    … …  
    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',
    … …  
    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
    … …  
    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,
    … …  
    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                ) );
    … …  
    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                ) );
    … …  
    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                ) );
    … …  
    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
    … …  
    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,
    … …  
    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" );
    … …  
    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' ) );
    … …  
    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" );
Note: See TracChangeset for help on using the changeset viewer.