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/link/getAdjacentPostLink.php

    r35242 r42343  
    99    protected $cat_id;
    1010
    11     public function setUp(){
     11    public function setUp() {
    1212        parent::setUp();
    13         $this->cat_id = self::factory()->category->create( array( 'name' => 'other' ) );
    14         $this->post_ids = array();
    15         $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );
    16         $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );
    17         $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );
    18         $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );
    19         $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );
     13        $this->cat_id     = self::factory()->category->create( array( 'name' => 'other' ) );
     14        $this->post_ids   = array();
     15        $this->post_ids[] = self::factory()->post->create(
     16            array(
     17                'post_type'   => 'post',
     18                'post_date'   => '2014-10-26 05:32:29',
     19                'category_id' => 1,
     20            )
     21        );
     22        $this->post_ids[] = self::factory()->post->create(
     23            array(
     24                'post_type'   => 'post',
     25                'post_date'   => '2014-10-26 04:32:29',
     26                'category_id' => $this->cat_id,
     27            )
     28        );
     29        $this->post_ids[] = self::factory()->post->create(
     30            array(
     31                'post_type'   => 'post',
     32                'post_date'   => '2014-10-26 03:32:29',
     33                'category_id' => 1,
     34            )
     35        );
     36        $this->post_ids[] = self::factory()->post->create(
     37            array(
     38                'post_type'   => 'post',
     39                'post_date'   => '2014-10-26 02:32:29',
     40                'category_id' => $this->cat_id,
     41            )
     42        );
     43        $this->post_ids[] = self::factory()->post->create(
     44            array(
     45                'post_type'   => 'post',
     46                'post_date'   => '2014-10-26 01:32:29',
     47                'category_id' => 1,
     48            )
     49        );
    2050
    2151        //set current post (has 2 on each end)
     
    2555
    2656    public function test_get_next_post_link_default() {
    27         $actual = get_next_post_link();
    28         $title = get_post( $this->post_ids[1] )->post_title;
     57        $actual   = get_next_post_link();
     58        $title    = get_post( $this->post_ids[1] )->post_title;
    2959        $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
    3060        $this->assertSame( $expected, $actual );
     
    3262
    3363    public function test_get_previous_post_link_default() {
    34         $actual = get_previous_post_link();
    35         $title = get_post( $this->post_ids[3] )->post_title;
     64        $actual   = get_previous_post_link();
     65        $title    = get_post( $this->post_ids[3] )->post_title;
    3666        $expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
    3767        $this->assertSame( $expected, $actual );
     
    3969
    4070    public function test_get_next_post_link_same_category() {
    41         $actual = get_next_post_link( '%link &raquo;', '%title', true );
    42         $title = get_post( $this->post_ids[1] )->post_title;
     71        $actual   = get_next_post_link( '%link &raquo;', '%title', true );
     72        $title    = get_post( $this->post_ids[1] )->post_title;
    4373        $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
    4474        $this->assertSame( $expected, $actual );
     
    4676
    4777    public function test_get_previous_post_link_same_category() {
    48         $actual = get_previous_post_link( '&laquo; %link', '%title', true );
    49         $title = get_post( $this->post_ids[3] )->post_title;
     78        $actual   = get_previous_post_link( '&laquo; %link', '%title', true );
     79        $title    = get_post( $this->post_ids[3] )->post_title;
    5080        $expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
    5181        $this->assertSame( $expected, $actual );
     
    5383
    5484    public function test_get_next_post_link_exclude_category() {
    55         $actual = get_next_post_link( '%link &raquo;', '%title', false, $this->cat_id );
    56         $title = get_post( $this->post_ids[1] )->post_title;
     85        $actual   = get_next_post_link( '%link &raquo;', '%title', false, $this->cat_id );
     86        $title    = get_post( $this->post_ids[1] )->post_title;
    5787        $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> &raquo;';
    5888        $this->assertSame( $expected, $actual );
     
    6090
    6191    public function test_get_previous_post_link_exclude_category() {
    62         $actual = get_previous_post_link( '&laquo; %link', '%title', false, $this->cat_id );
    63         $title = get_post( $this->post_ids[3] )->post_title;
     92        $actual   = get_previous_post_link( '&laquo; %link', '%title', false, $this->cat_id );
     93        $title    = get_post( $this->post_ids[3] )->post_title;
    6494        $expected = '&laquo; <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>';
    6595        $this->assertSame( $expected, $actual );
Note: See TracChangeset for help on using the changeset viewer.