Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/import/import.php

    r41169 r42343  
    1010        parent::setUp();
    1111
    12         if ( ! defined( 'WP_IMPORTING' ) )
     12        if ( ! defined( 'WP_IMPORTING' ) ) {
    1313            define( 'WP_IMPORTING', true );
    14 
    15         if ( ! defined( 'WP_LOAD_IMPORTERS' ) )
     14        }
     15
     16        if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
    1617            define( 'WP_LOAD_IMPORTERS', true );
     18        }
    1719
    1820        add_filter( 'import_allow_create_users', '__return_true' );
     
    2628        global $wpdb;
    2729        // crude but effective: make sure there's no residual data in the main tables
    28         foreach ( array('posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta') as $table)
    29             $wpdb->query("DELETE FROM {$wpdb->$table}");
     30        foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) {
     31            $wpdb->query( "DELETE FROM {$wpdb->$table}" );
     32        }
    3033    }
    3134
     
    3942        global $wpdb;
    4043
    41         $authors = array( 'admin' => false, 'editor' => false, 'author' => false );
     44        $authors = array(
     45            'admin'  => false,
     46            'editor' => false,
     47            'author' => false,
     48        );
    4249        $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
    4350
     
    6269        $foo = get_term_by( 'slug', 'foo', 'category' );
    6370        $this->assertEquals( 0, $foo->parent );
    64         $bar = get_term_by( 'slug', 'bar', 'category' );
     71        $bar     = get_term_by( 'slug', 'bar', 'category' );
    6572        $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
    6673        $this->assertEquals( $bar->term_id, $foo_bar->parent );
     
    7683        $this->assertEquals( 1, $comment_count->total_comments );
    7784
    78         $posts = get_posts( array( 'numberposts' => 20, 'post_type' => 'any', 'post_status' => 'any', 'orderby' => 'ID' ) );
    79         $this->assertEquals( 11, count($posts) );
     85        $posts = get_posts(
     86            array(
     87                'numberposts' => 20,
     88                'post_type'   => 'any',
     89                'post_status' => 'any',
     90                'orderby'     => 'ID',
     91            )
     92        );
     93        $this->assertEquals( 11, count( $posts ) );
    8094
    8195        $post = $posts[0];
     
    87101        $this->assertEquals( 0, $post->post_parent );
    88102        $cats = wp_get_post_categories( $post->ID );
    89         $this->assertEquals( 27, count($cats) );
     103        $this->assertEquals( 27, count( $cats ) );
    90104
    91105        $post = $posts[1];
     
    97111        $this->assertEquals( 0, $post->post_parent );
    98112        $cats = wp_get_post_categories( $post->ID );
    99         $this->assertEquals( 1, count($cats) );
     113        $this->assertEquals( 1, count( $cats ) );
    100114        $this->assertTrue( has_post_format( 'aside', $post->ID ) );
    101115
     
    108122        $this->assertEquals( 0, $post->post_parent );
    109123        $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
    110         $this->assertEquals( 1, count($cats) );
     124        $this->assertEquals( 1, count( $cats ) );
    111125        $this->assertEquals( 'foo', $cats[0]->slug );
    112126
     
    119133        $this->assertEquals( 0, $post->post_parent );
    120134        $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
    121         $this->assertEquals( 1, count($cats) );
     135        $this->assertEquals( 1, count( $cats ) );
    122136        $this->assertEquals( 'foo-bar', $cats[0]->slug );
    123137
     
    130144        $this->assertEquals( 0, $post->post_parent );
    131145        $cats = wp_get_post_categories( $post->ID );
    132         $this->assertEquals( 1, count($cats) );
     146        $this->assertEquals( 1, count( $cats ) );
    133147        $tags = wp_get_post_tags( $post->ID );
    134         $this->assertEquals( 3, count($tags) );
     148        $this->assertEquals( 3, count( $tags ) );
    135149        $this->assertEquals( 'tag1', $tags[0]->slug );
    136150        $this->assertEquals( 'tag2', $tags[1]->slug );
     
    190204        $this->assertEquals( 0, $post->post_parent );
    191205        $cats = wp_get_post_categories( $post->ID );
    192         $this->assertEquals( 1, count($cats) );
     206        $this->assertEquals( 1, count( $cats ) );
    193207    }
    194208
    195209    function test_double_import() {
    196         $authors = array( 'admin' => false, 'editor' => false, 'author' => false );
     210        $authors = array(
     211            'admin'  => false,
     212            'editor' => false,
     213            'author' => false,
     214        );
    197215        $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
    198216        $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors );
     
    216234        $foo = get_term_by( 'slug', 'foo', 'category' );
    217235        $this->assertEquals( 0, $foo->parent );
    218         $bar = get_term_by( 'slug', 'bar', 'category' );
     236        $bar     = get_term_by( 'slug', 'bar', 'category' );
    219237        $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
    220238        $this->assertEquals( $bar->term_id, $foo_bar->parent );
     
    233251        global $wp_importers;
    234252        $_wp_importers = $wp_importers; // Preserve global state
    235         $wp_importers = array(
     253        $wp_importers  = array(
    236254            'xyz1' => array( 'xyz1' ),
    237255            'XYZ2' => array( 'XYZ2' ),
     
    240258            'def1' => array( 'def1' ),
    241259        );
    242         $this->assertEquals( array(
    243             'ABC1' => array( 'ABC1' ),
    244             'abc2' => array( 'abc2' ),
    245             'def1' => array( 'def1' ),
    246             'xyz1' => array( 'xyz1' ),
    247             'XYZ2' => array( 'XYZ2' ),
    248         ), get_importers() );
     260        $this->assertEquals(
     261            array(
     262                'ABC1' => array( 'ABC1' ),
     263                'abc2' => array( 'abc2' ),
     264                'def1' => array( 'def1' ),
     265                'xyz1' => array( 'xyz1' ),
     266                'XYZ2' => array( 'XYZ2' ),
     267            ), get_importers()
     268        );
    249269        $wp_importers = $_wp_importers; // Restore global state
    250270    }
     
    265285        $this->assertSame( "foo\'bar", $tag1->name );
    266286
    267         $posts = get_posts( array( 'post_type' => 'any', 'post_status' => 'any' ) );
     287        $posts = get_posts(
     288            array(
     289                'post_type'   => 'any',
     290                'post_status' => 'any',
     291            )
     292        );
    268293        $this->assertSame( 'Slashes aren\\\'t \"cool\"', $posts[0]->post_content );
    269294    }
Note: See TracChangeset for help on using the changeset viewer.