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/post/template.php

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