Changeset 35857
- Timestamp:
- 12/11/2015 02:26:43 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/getCommentLink.php
r35331 r35857 5 5 */ 6 6 class Tests_Comment_GetCommentLink extends WP_UnitTestCase { 7 protected $p;8 protected $comments = array();7 protected static $p; 8 protected static $comments = array(); 9 9 10 public function setUp() { 11 parent::setUp(); 10 public static function wpSetUpBeforeClass( $factory ) { 11 $now = time(); 12 self::$p = self::factory()->post->create(); 12 13 13 $now = time(); 14 $this->p = self::factory()->post->create(); 15 $this->comments[] = self::factory()->comment->create( array( 16 'comment_post_ID' => $this->p, 14 self::$comments[] = self::factory()->comment->create( array( 15 'comment_post_ID' => self::$p, 17 16 'comment_content' => '1', 18 17 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), 19 18 ) ); 20 $this->comments[] = self::factory()->comment->create( array(21 'comment_post_ID' => $this->p,19 self::$comments[] = self::factory()->comment->create( array( 20 'comment_post_ID' => self::$p, 22 21 'comment_content' => '2', 23 22 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), 24 23 ) ); 25 $this->comments[] = self::factory()->comment->create( array(26 'comment_post_ID' => $this->p,24 self::$comments[] = self::factory()->comment->create( array( 25 'comment_post_ID' => self::$p, 27 26 'comment_content' => '3', 28 27 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), 29 28 ) ); 30 $this->comments[] = self::factory()->comment->create( array(31 'comment_post_ID' => $this->p,29 self::$comments[] = self::factory()->comment->create( array( 30 'comment_post_ID' => self::$p, 32 31 'comment_content' => '4', 33 32 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), 34 33 ) ); 35 $this->comments[] = self::factory()->comment->create( array(36 'comment_post_ID' => $this->p,34 self::$comments[] = self::factory()->comment->create( array( 35 'comment_post_ID' => self::$p, 37 36 'comment_content' => '4', 38 37 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), 39 38 ) ); 40 $this->comments[] = self::factory()->comment->create( array(41 'comment_post_ID' => $this->p,39 self::$comments[] = self::factory()->comment->create( array( 40 'comment_post_ID' => self::$p, 42 41 'comment_content' => '4', 43 42 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), 44 43 ) ); 44 45 } 46 47 public static function wpTearDownAfterClass() { 48 foreach ( self::$comments as $c ) { 49 wp_delete_comment( $c, true ); 50 } 51 52 wp_delete_post( self::$p ); 45 53 } 46 54 … … 53 61 update_option( 'comments_per_page', 2 ); 54 62 55 $found = get_comment_link( $this->comments[1] );63 $found = get_comment_link( self::$comments[1] ); 56 64 57 65 $this->assertContains( 'cpage=3', $found ); … … 66 74 update_option( 'comments_per_page', 2 ); 67 75 68 $found = get_comment_link( $this->comments[3] );76 $found = get_comment_link( self::$comments[3] ); 69 77 70 78 $this->assertContains( 'cpage=2', $found ); … … 79 87 update_option( 'comments_per_page', 2 ); 80 88 81 $found = get_comment_link( $this->comments[5] );89 $found = get_comment_link( self::$comments[5] ); 82 90 83 91 $this->assertContains( 'cpage=1', $found ); … … 91 99 update_option( 'comments_per_page', 2 ); 92 100 93 $found = get_comment_link( $this->comments[5] );101 $found = get_comment_link( self::$comments[5] ); 94 102 95 103 $this->assertNotContains( 'cpage', $found ); … … 104 112 update_option( 'comments_per_page', 2 ); 105 113 106 $found = get_comment_link( $this->comments[3] );114 $found = get_comment_link( self::$comments[3] ); 107 115 108 116 $this->assertContains( 'cpage=2', $found ); … … 117 125 update_option( 'comments_per_page', 2 ); 118 126 119 $found = get_comment_link( $this->comments[1] );127 $found = get_comment_link( self::$comments[1] ); 120 128 121 129 $this->assertContains( 'cpage=3', $found );
Note: See TracChangeset
for help on using the changeset viewer.