Changeset 35225 for trunk/tests/phpunit/tests/link/getAdjacentPostLink.php
- Timestamp:
- 10/16/2015 09:04:12 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/link/getAdjacentPostLink.php
r31097 r35225 11 11 public function setUp(){ 12 12 parent::setUp(); 13 $this->cat_id = $this->factory->category->create( array( 'name' => 'other' ) );13 $this->cat_id = self::$factory->category->create( array( 'name' => 'other' ) ); 14 14 $this->post_ids = array(); 15 $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) );16 $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) );17 $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) );18 $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) );19 $this->post_ids[] = $this->factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) );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 ) ); 20 20 21 21 //set current post (has 2 on each end) … … 26 26 public function test_get_next_post_link_default() { 27 27 $actual = get_next_post_link(); 28 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> »'; 28 $title = get_post( $this->post_ids[1] )->post_title; 29 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 29 30 $this->assertSame( $expected, $actual ); 30 31 } … … 32 33 public function test_get_previous_post_link_default() { 33 34 $actual = get_previous_post_link(); 34 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>'; 35 $title = get_post( $this->post_ids[3] )->post_title; 36 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 35 37 $this->assertSame( $expected, $actual ); 36 38 } … … 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="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> »'; 42 $title = get_post( $this->post_ids[1] )->post_title; 43 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 41 44 $this->assertSame( $expected, $actual ); 42 45 } … … 44 47 public function test_get_previous_post_link_same_category() { 45 48 $actual = get_previous_post_link( '« %link', '%title', true ); 46 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>'; 49 $title = get_post( $this->post_ids[3] )->post_title; 50 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 47 51 $this->assertSame( $expected, $actual ); 48 52 } … … 50 54 public function test_get_next_post_link_exclude_category() { 51 55 $actual = get_next_post_link( '%link »', '%title', false, $this->cat_id ); 52 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">Post title 2</a> »'; 56 $title = get_post( $this->post_ids[1] )->post_title; 57 $expected = '<a href="' . home_url( '?p=' . $this->post_ids[1] ) . '" rel="next">' . $title . '</a> »'; 53 58 $this->assertSame( $expected, $actual ); 54 59 } … … 56 61 public function test_get_previous_post_link_exclude_category() { 57 62 $actual = get_previous_post_link( '« %link', '%title', false, $this->cat_id ); 58 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">Post title 4</a>'; 63 $title = get_post( $this->post_ids[3] )->post_title; 64 $expected = '« <a href="' . home_url( '?p=' . $this->post_ids[3] ) . '" rel="prev">' . $title . '</a>'; 59 65 $this->assertSame( $expected, $actual ); 60 66 }
Note: See TracChangeset
for help on using the changeset viewer.