Changeset 42343 for trunk/tests/phpunit/tests/link/getAdjacentPostLink.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/link/getAdjacentPostLink.php
r35242 r42343 9 9 protected $cat_id; 10 10 11 public function setUp() {11 public function setUp() { 12 12 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 ); 20 50 21 51 //set current post (has 2 on each end) … … 25 55 26 56 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; 29 59 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 30 60 $this->assertSame( $expected, $actual ); … … 32 62 33 63 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; 36 66 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 37 67 $this->assertSame( $expected, $actual ); … … 39 69 40 70 public function test_get_next_post_link_same_category() { 41 $actual = get_next_post_link( '%link »', '%title', true );42 $title = get_post( $this->post_ids[1] )->post_title;71 $actual = get_next_post_link( '%link »', '%title', true ); 72 $title = get_post( $this->post_ids[1] )->post_title; 43 73 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 44 74 $this->assertSame( $expected, $actual ); … … 46 76 47 77 public function test_get_previous_post_link_same_category() { 48 $actual = get_previous_post_link( '« %link', '%title', true );49 $title = get_post( $this->post_ids[3] )->post_title;78 $actual = get_previous_post_link( '« %link', '%title', true ); 79 $title = get_post( $this->post_ids[3] )->post_title; 50 80 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 51 81 $this->assertSame( $expected, $actual ); … … 53 83 54 84 public function test_get_next_post_link_exclude_category() { 55 $actual = get_next_post_link( '%link »', '%title', false, $this->cat_id );56 $title = get_post( $this->post_ids[1] )->post_title;85 $actual = get_next_post_link( '%link »', '%title', false, $this->cat_id ); 86 $title = get_post( $this->post_ids[1] )->post_title; 57 87 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 58 88 $this->assertSame( $expected, $actual ); … … 60 90 61 91 public function test_get_previous_post_link_exclude_category() { 62 $actual = get_previous_post_link( '« %link', '%title', false, $this->cat_id );63 $title = get_post( $this->post_ids[3] )->post_title;92 $actual = get_previous_post_link( '« %link', '%title', false, $this->cat_id ); 93 $title = get_post( $this->post_ids[3] )->post_title; 64 94 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 65 95 $this->assertSame( $expected, $actual );
Note: See TracChangeset
for help on using the changeset viewer.