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/avatar.php

    r35242 r42343  
    2323
    2424        $args = array( 'size' => 100 );
    25         $url = get_avatar_url( 1, $args );
     25        $url  = get_avatar_url( 1, $args );
    2626        $this->assertEquals( preg_match( '|\?.*s=100|', $url ), 1 );
    2727    }
     
    3535
    3636        $args = array( 'default' => 'wavatar' );
    37         $url = get_avatar_url( 1, $args );
     37        $url  = get_avatar_url( 1, $args );
    3838        $this->assertEquals( preg_match( '|\?.*d=wavatar|', $url ), 1 );
    3939
    4040        $this->assertEquals( preg_match( '|\?.*f=y|', $url ), 0 );
    4141        $args = array( 'force_default' => true );
    42         $url = get_avatar_url( 1, $args );
     42        $url  = get_avatar_url( 1, $args );
    4343        $this->assertEquals( preg_match( '|\?.*f=y|', $url ), 1 );
    4444    }
     
    5252
    5353        $args = array( 'rating' => 'M' );
    54         $url = get_avatar_url( 1, $args );
     54        $url  = get_avatar_url( 1, $args );
    5555        $this->assertEquals( preg_match( '|\?.*r=m|', $url ), 1 );
    5656    }
     
    6464
    6565        $args = array( 'scheme' => 'https' );
    66         $url = get_avatar_url( 1, $args );
     66        $url  = get_avatar_url( 1, $args );
    6767        $this->assertEquals( preg_match( '|^https://|', $url ), 1 );
    6868
    6969        $args = array( 'scheme' => 'lolcat' );
    70         $url = get_avatar_url( 1, $args );
     70        $url  = get_avatar_url( 1, $args );
    7171        $this->assertEquals( preg_match( '|^lolcat://|', $url ), 0 );
    7272    }
     
    8989
    9090        $post_id = self::factory()->post->create( array( 'post_author' => 1 ) );
    91         $post = get_post( $post_id );
    92         $url2 = get_avatar_url( $post );
    93         $this->assertEquals( $url, $url2 );
    94 
    95         $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) );
    96         $comment = get_comment( $comment_id );
    97         $url2 = get_avatar_url( $comment );
     91        $post    = get_post( $post_id );
     92        $url2    = get_avatar_url( $post );
     93        $this->assertEquals( $url, $url2 );
     94
     95        $comment_id = self::factory()->comment->create(
     96            array(
     97                'comment_post_ID' => $post_id,
     98                'user_id'         => 1,
     99            )
     100        );
     101        $comment    = get_comment( $comment_id );
     102        $url2       = get_avatar_url( $comment );
    98103        $this->assertEquals( $url, $url2 );
    99104    }
     
    139144        $url = get_avatar_url( 1 );
    140145
    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' ) );
    143         $comment = get_comment( $comment_id );
     146        $post_id    = self::factory()->post->create( array( 'post_author' => 1 ) );
     147        $comment_id = self::factory()->comment->create(
     148            array(
     149                'comment_post_ID' => $post_id,
     150                'user_id'         => 1,
     151                'comment_type'    => 'pingback',
     152            )
     153        );
     154        $comment    = get_comment( $comment_id );
    144155
    145156        $url2 = get_avatar_url( $comment );
     
    164175    public function test_get_avatar_size() {
    165176        $size = '100';
    166         $img = get_avatar( 1, $size );
     177        $img  = get_avatar( 1, $size );
    167178        $this->assertEquals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 );
    168179    }
     
    176187    public function test_get_avatar_class() {
    177188        $class = 'first';
    178         $img = get_avatar( 1, 96, '', '', array( 'class' => $class ) );
     189        $img   = get_avatar( 1, 96, '', '', array( 'class' => $class ) );
    179190        $this->assertEquals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 );
    180191    }
Note: See TracChangeset for help on using the changeset viewer.