Make WordPress Core


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

    r38398 r42343  
    1717
    1818                $this->month_url = get_month_link( date( 'Y' ), date( 'm' ) );
    19                 $this->year_url = get_year_link( date( 'Y' ) );
     19                $this->year_url  = get_year_link( date( 'Y' ) );
    2020        }
    2121
    2222        public static function wpSetUpBeforeClass( $factory ) {
    23                 self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
     23                self::$post_ids = $factory->post->create_many(
     24                        8, array(
     25                                'post_type'   => 'post',
     26                                'post_author' => '1',
     27                        )
     28                );
    2429        }
    2530
    2631        function test_wp_get_archives_default() {
    27                 $expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . "</a></li>";
     32                $expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>';
    2833                $this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) );
    2934        }
    3035
    3136        function test_wp_get_archives_type() {
    32                 $expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . "</a></li>";
    33                 $this->assertEquals( $expected['type'], trim( wp_get_archives( array( 'echo' => false, 'type' => 'yearly' ) ) ) );
     37                $expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . '</a></li>';
     38                $this->assertEquals(
     39                        $expected['type'], trim(
     40                                wp_get_archives(
     41                                        array(
     42                                                'echo' => false,
     43                                                'type' => 'yearly',
     44                                        )
     45                                )
     46                        )
     47                );
    3448        }
    3549
    … …  
    5670        <li><a href='$link5'>$title5</a></li>
    5771EOF;
    58                 $this->assertEquals( $expected['limit'], trim( wp_get_archives( array( 'echo' => false, 'type' => 'postbypost', 'limit' => 5 ) ) ) );
     72                $this->assertEquals(
     73                        $expected['limit'], trim(
     74                                wp_get_archives(
     75                                        array(
     76                                                'echo'  => false,
     77                                                'type'  => 'postbypost',
     78                                                'limit' => 5,
     79                                        )
     80                                )
     81                        )
     82                );
    5983        }
    6084
    6185        function test_wp_get_archives_format() {
    6286                $expected['format'] = "<option value='" . $this->month_url . "'> " . date( 'F Y' ) . ' </option>';
    63                 $this->assertEquals( $expected['format'], trim( wp_get_archives( array( 'echo' => false, 'format' => 'option' ) ) ) );
     87                $this->assertEquals(
     88                        $expected['format'], trim(
     89                                wp_get_archives(
     90                                        array(
     91                                                'echo'   => false,
     92                                                'format' => 'option',
     93                                        )
     94                                )
     95                        )
     96                );
    6497        }
    6598
    6699        function test_wp_get_archives_before_and_after() {
    67100                $expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></div>';
    68                 $this->assertEquals( $expected['before_and_after'], trim( wp_get_archives( array( 'echo' => false, 'format' => 'custom', 'before' => '<div>', 'after' => '</div>' ) ) ) );
     101                $this->assertEquals(
     102                        $expected['before_and_after'], trim(
     103                                wp_get_archives(
     104                                        array(
     105                                                'echo'   => false,
     106                                                'format' => 'custom',
     107                                                'before' => '<div>',
     108                                                'after'  => '</div>',
     109                                        )
     110                                )
     111                        )
     112                );
    69113        }
    70114
    71115        function test_wp_get_archives_show_post_count() {
    72                 $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . "</a>&nbsp;(8)</li>";
    73                 $this->assertEquals( $expected['show_post_count'], trim( wp_get_archives( array( 'echo' => false, 'show_post_count' => 1 ) ) ) );
     116                $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a>&nbsp;(8)</li>';
     117                $this->assertEquals(
     118                        $expected['show_post_count'], trim(
     119                                wp_get_archives(
     120                                        array(
     121                                                'echo'            => false,
     122                                                'show_post_count' => 1,
     123                                        )
     124                                )
     125                        )
     126                );
    74127        }
    75128
    … …  
    83136
    84137        function test_wp_get_archives_order() {
    85                 self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) );
    86 
    87                 $date_full = date( 'F Y' );
    88                 $oct_url = get_month_link( 2012, 10 );
     138                self::factory()->post->create(
     139                        array(
     140                                'post_type'   => 'post',
     141                                'post_author' => '1',
     142                                'post_date'   => '2012-10-23 19:34:42',
     143                        )
     144                );
     145
     146                $date_full             = date( 'F Y' );
     147                $oct_url               = get_month_link( 2012, 10 );
    89148                $expected['order_asc'] = <<<EOF
    90149<li><a href='{$oct_url}'>October 2012</a></li>
    91150        <li><a href='{$this->month_url}'>$date_full</a></li>
    92151EOF;
    93                 $this->assertEquals( $expected['order_asc'], trim( wp_get_archives( array( 'echo' => false, 'order' => 'ASC' ) ) ) );
     152                $this->assertEquals(
     153                        $expected['order_asc'], trim(
     154                                wp_get_archives(
     155                                        array(
     156                                                'echo'  => false,
     157                                                'order' => 'ASC',
     158                                        )
     159                                )
     160                        )
     161                );
    94162
    95163                $expected['order_desc'] = <<<EOF
    … …  
    97165        <li><a href='{$oct_url}'>October 2012</a></li>
    98166EOF;
    99                 $this->assertEquals( $expected['order_desc'], trim( wp_get_archives( array( 'echo' => false, 'order' => 'DESC' ) ) ) );
     167                $this->assertEquals(
     168                        $expected['order_desc'], trim(
     169                                wp_get_archives(
     170                                        array(
     171                                                'echo'  => false,
     172                                                'order' => 'DESC',
     173                                        )
     174                                )
     175                        )
     176                );
    100177        }
    101178
    … …  
    106183                register_post_type( 'taco', array( 'public' => true ) );
    107184
    108                 self::factory()->post->create( array(
    109                         'post_type' => 'taco',
    110                         'post_author' => '1',
    111                         'post_date' => '2014-10-23 19:34:42'
    112                 ) );
    113 
    114                 $oct_url = esc_url( add_query_arg( 'post_type', 'taco', get_month_link( 2014, 10 ) ) );
     185                self::factory()->post->create(
     186                        array(
     187                                'post_type'   => 'taco',
     188                                'post_author' => '1',
     189                                'post_date'   => '2014-10-23 19:34:42',
     190                        )
     191                );
     192
     193                $oct_url  = esc_url( add_query_arg( 'post_type', 'taco', get_month_link( 2014, 10 ) ) );
    115194                $expected = "<li><a href='{$oct_url}'>October 2014</a></li>";
    116                 $archives = wp_get_archives( array( 'echo' => false, 'post_type' => 'taco' ) );
     195                $archives = wp_get_archives(
     196                        array(
     197                                'echo'      => false,
     198                                'post_type' => 'taco',
     199                        )
     200                );
    117201                $this->assertEquals( $expected, trim( $archives ) );
    118202        }
Note: See TracChangeset for help on using the changeset viewer.