Changeset 38372
- Timestamp:
- 08/26/2016 05:41:51 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesComment.php
r35242 r38372 6 6 */ 7 7 class Tests_Admin_IncludesComment extends WP_UnitTestCase { 8 public function test_must_match_date_and_author() { 9 $p1 = self::factory()->post->create(); 10 $c1 = self::factory()->comment->create( array( 11 'comment_author' => 1, 12 'comment_date' => '2014-05-06 12:00:00', 13 'comment_post_ID' => $p1, 8 /** 9 * Post ID to add comments to. 10 * 11 * @var int 12 */ 13 public static $post_id; 14 15 /** 16 * Comment IDs. 17 * 18 * @var array 19 */ 20 public static $comment_ids = array(); 21 22 /** 23 * Create the post and comments for the tests. 24 * 25 * @param WP_UnitTest_Factory $factory 26 */ 27 public static function wpSetUpBeforeClass( $factory ) { 28 self::$post_id = $factory->post->create(); 29 30 self::$comment_ids[] = $factory->comment->create( array( 31 'comment_author' => 1, 32 'comment_date' => '2014-05-06 12:00:00', 33 'comment_date_gmt' => '2014-05-06 07:00:00', 34 'comment_post_ID' => self::$post_id, 14 35 ) ); 15 36 16 $p2 = self::factory()->post->create(); 17 $c2 = self::factory()->comment->create( array( 18 'comment_author' => 2, 19 'comment_date' => '2004-01-02 12:00:00', 20 'comment_post_ID' => $p2, 37 self::$comment_ids[] = $factory->comment->create( array( 38 'comment_author' => 2, 39 'comment_date' => '2004-01-02 12:00:00', 40 'comment_post_ID' => self::$post_id, 21 41 ) ); 42 } 22 43 44 /** 45 * Delete the post and comments for the tests. 46 */ 47 public static function wpTearDownAfterClass() { 48 foreach ( self::$comment_ids as $comment_id ) { 49 wp_delete_comment( $comment_id, true ); 50 } 51 52 wp_delete_post( self::$post_id, true ); 53 } 54 55 /** 56 * Verify that both the comment date and author must match for a comment to exist. 57 */ 58 public function test_must_match_date_and_author() { 23 59 $this->assertNull( comment_exists( 1, '2004-01-02 12:00:00' ) ); 24 $this->assertEquals( $p1, comment_exists( 1, '2014-05-06 12:00:00' ) );60 $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) ); 25 61 } 26 62 … … 29 65 */ 30 66 public function test_default_value_of_timezone_should_be_blog() { 31 $p = self::factory()->post->create(); 32 $c = self::factory()->comment->create( array( 33 'comment_author' => 1, 34 'comment_post_ID' => $p, 35 'comment_date' => '2014-05-06 12:00:00', 36 'comment_date_gmt' => '2014-05-06 07:00:00', 37 ) ); 38 39 $this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00' ) ); 67 $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00' ) ); 40 68 } 41 69 … … 44 72 */ 45 73 public function test_should_respect_timezone_blog() { 46 $p = self::factory()->post->create(); 47 $c = self::factory()->comment->create( array( 48 'comment_author' => 1, 49 'comment_post_ID' => $p, 50 'comment_date' => '2014-05-06 12:00:00', 51 'comment_date_gmt' => '2014-05-06 07:00:00', 52 ) ); 53 54 $this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00', 'blog' ) ); 74 $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'blog' ) ); 55 75 } 56 76 … … 59 79 */ 60 80 public function test_should_respect_timezone_gmt() { 61 $p = self::factory()->post->create(); 62 $c = self::factory()->comment->create( array( 63 'comment_author' => 1, 64 'comment_post_ID' => $p, 65 'comment_date' => '2014-05-06 12:00:00', 66 'comment_date_gmt' => '2014-05-06 07:00:00', 67 ) ); 68 69 $this->assertEquals( $p, comment_exists( 1, '2014-05-06 07:00:00', 'gmt' ) ); 81 $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 07:00:00', 'gmt' ) ); 70 82 } 71 83 … … 74 86 */ 75 87 public function test_invalid_timezone_should_fall_back_on_blog() { 76 $p = self::factory()->post->create(); 77 $c = self::factory()->comment->create( array( 78 'comment_author' => 1, 79 'comment_post_ID' => $p, 80 'comment_date' => '2014-05-06 12:00:00', 81 'comment_date_gmt' => '2014-05-06 07:00:00', 82 ) ); 83 84 $this->assertEquals( $p, comment_exists( 1, '2014-05-06 12:00:00', 'not_a_valid_value' ) ); 88 $this->assertEquals( self::$post_id, comment_exists( 1, '2014-05-06 12:00:00', 'not_a_valid_value' ) ); 85 89 } 86 90 }
Note: See TracChangeset
for help on using the changeset viewer.