Ticket #30955: getAdjacentPostLink.patch
File getAdjacentPostLink.patch, 2.9 KB (added by , 8 years ago) |
---|
-
tests/phpunit/tests/link/getAdjacentPostLink.php
7 7 8 8 protected $post_ids; 9 9 protected $cat_id; 10 protected $link; 10 11 11 12 public function setUp(){ 12 13 parent::setUp(); … … 21 22 //set current post (has 2 on each end) 22 23 global $GLOBALS; 23 24 $GLOBALS['post'] = get_post( $this->post_ids[2] ); 25 $this->site_url = get_site_url(); 24 26 } 25 27 26 28 public function test_get_next_post_link_default() { 27 29 $actual = get_next_post_link(); 28 $expected = '<a href=" http://example.org/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »';30 $expected = '<a href="' . $this->site_url . '/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »'; 29 31 $this->assertSame( $expected, $actual ); 30 32 } 31 33 32 34 public function test_get_previous_post_link_default() { 33 35 $actual = get_previous_post_link(); 34 $expected = '« <a href=" http://example.org/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>';36 $expected = '« <a href="' . $this->site_url . '/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>'; 35 37 $this->assertSame( $expected, $actual ); 36 38 } 37 39 38 40 public function test_get_next_post_link_same_category() { 39 41 $actual = get_next_post_link( '%link »', '%title', true ); 40 $expected = '<a href=" http://example.org/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »';42 $expected = '<a href="' . $this->site_url . '/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »'; 41 43 $this->assertSame( $expected, $actual ); 42 44 } 43 45 44 46 public function test_get_previous_post_link_same_category() { 45 47 $actual = get_previous_post_link( '« %link', '%title', true ); 46 $expected = '« <a href=" http://example.org/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>';48 $expected = '« <a href="' . $this->site_url . '/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>'; 47 49 $this->assertSame( $expected, $actual ); 48 50 } 49 51 50 52 public function test_get_next_post_link_exclude_category() { 51 53 $actual = get_next_post_link( '%link »', '%title', false, $this->cat_id ); 52 $expected = '<a href=" http://example.org/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »';54 $expected = '<a href="' . $this->site_url . '/?p=' . $this->post_ids[1] . '" rel="next">Post title 2</a> »'; 53 55 $this->assertSame( $expected, $actual ); 54 56 } 55 57 56 58 public function test_get_previous_post_link_exclude_category() { 57 59 $actual = get_previous_post_link( '« %link', '%title', false, $this->cat_id ); 58 $expected = '« <a href=" http://example.org/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>';60 $expected = '« <a href="' . $this->site_url . '/?p=' . $this->post_ids[3] . '" rel="prev">Post title 4</a>'; 59 61 $this->assertSame( $expected, $actual ); 60 62 } 61 63 }