Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/term/getTheTerms.php

    r40353 r42343  
    55 */
    66class Tests_Term_GetTheTerms extends WP_UnitTestCase {
    7     protected $taxonomy = 'category';
     7    protected $taxonomy        = 'category';
    88    protected static $post_ids = array();
    99
     
    1818        $post_id = self::$post_ids[0];
    1919
    20         $terms_1 = array('foo', 'bar', 'baz');
    21         $terms_2 = array('bar', 'bing');
     20        $terms_1 = array( 'foo', 'bar', 'baz' );
     21        $terms_2 = array( 'bar', 'bing' );
    2222
    2323        // Cache should be empty after a set.
    2424        $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy );
    25         $this->assertEquals( 3, count($tt_1) );
    26         $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships') );
     25        $this->assertEquals( 3, count( $tt_1 ) );
     26        $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) );
    2727
    2828        // wp_get_object_terms() does not prime the cache.
    29         wp_get_object_terms( $post_id, $this->taxonomy, array('fields' => 'names', 'orderby' => 't.term_id') );
    30         $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships') );
     29        wp_get_object_terms(
     30            $post_id, $this->taxonomy, array(
     31                'fields'  => 'names',
     32                'orderby' => 't.term_id',
     33            )
     34        );
     35        $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) );
    3136
    3237        // get_the_terms() does prime the cache.
    3338        $terms = get_the_terms( $post_id, $this->taxonomy );
    34         $cache = wp_cache_get( $post_id, $this->taxonomy . '_relationships');
     39        $cache = wp_cache_get( $post_id, $this->taxonomy . '_relationships' );
    3540        $this->assertInternalType( 'array', $cache );
    3641
    3742        // Cache should be empty after a set.
    3843        $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy );
    39         $this->assertEquals( 2, count($tt_2) );
    40         $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships') );
     44        $this->assertEquals( 2, count( $tt_2 ) );
     45        $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) );
    4146    }
    4247
     
    4651    function test_object_term_cache_when_term_changes() {
    4752        $post_id = self::$post_ids[0];
    48         $tag_id = self::factory()->tag->create( array(
    49             'name' => 'Amaze Tag',
    50             'description' => 'My Amazing Tag'
    51         ) );
     53        $tag_id  = self::factory()->tag->create(
     54            array(
     55                'name'        => 'Amaze Tag',
     56                'description' => 'My Amazing Tag',
     57            )
     58        );
    5259
    5360        $tt_1 = wp_set_object_terms( $post_id, $tag_id, 'post_tag' );
     
    5764        $this->assertEquals( 'My Amazing Tag', $terms[0]->description );
    5865
    59         $_updated = wp_update_term( $tag_id, 'post_tag', array(
    60             'description' => 'This description is even more amazing!'
    61         ) );
     66        $_updated = wp_update_term(
     67            $tag_id, 'post_tag', array(
     68                'description' => 'This description is even more amazing!',
     69            )
     70        );
    6271
    6372        $_new_term = get_term( $tag_id, 'post_tag' );
     
    126135        $p = self::$post_ids[0];
    127136
    128         $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'fff' ) );
    129         $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'aaa' ) );
    130         $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'zzz' ) );
     137        $t1 = self::factory()->term->create(
     138            array(
     139                'taxonomy' => 'wptests_tax',
     140                'name'     => 'fff',
     141            )
     142        );
     143        $t2 = self::factory()->term->create(
     144            array(
     145                'taxonomy' => 'wptests_tax',
     146                'name'     => 'aaa',
     147            )
     148        );
     149        $t3 = self::factory()->term->create(
     150            array(
     151                'taxonomy' => 'wptests_tax',
     152                'name'     => 'zzz',
     153            )
     154        );
    131155
    132156        wp_set_object_terms( $p, array( $t1, $t2, $t3 ), 'wptests_tax' );
     
    142166     */
    143167    function test_get_the_terms_should_return_wp_error_when_taxonomy_is_unregistered() {
    144         $p = self::$post_ids[0];
     168        $p     = self::$post_ids[0];
    145169        $terms = get_the_terms( $p, 'this-taxonomy-does-not-exist' );
    146170        $this->assertWPError( $terms );
     
    184208
    185209        $num_queries = $wpdb->num_queries;
    186         $found = get_the_terms( self::$post_ids[0], 'wptests_tax' );
     210        $found       = get_the_terms( self::$post_ids[0], 'wptests_tax' );
    187211
    188212        $this->assertEqualSets( $terms, wp_list_pluck( $found, 'term_id' ) );
     
    203227
    204228        // Create Test Category.
    205         $term_id = self::factory()->term->create( array(
    206             'taxonomy' => 'wptests_tax',
    207         ) );
     229        $term_id = self::factory()->term->create(
     230            array(
     231                'taxonomy' => 'wptests_tax',
     232            )
     233        );
    208234
    209235        $post_id = self::factory()->post->create();
     
    230256
    231257        // Create Test Category.
    232         $term_ids = self::factory()->term->create_many( 2, array(
    233             'taxonomy' => 'wptests_tax',
    234         ) );
     258        $term_ids = self::factory()->term->create_many(
     259            2, array(
     260                'taxonomy' => 'wptests_tax',
     261            )
     262        );
    235263
    236264        $post_id = self::factory()->post->create();
Note: See TracChangeset for help on using the changeset viewer.