Changeset 39189 for trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php
- Timestamp:
- 11/10/2016 01:53:08 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php
r35242 r39189 5 5 */ 6 6 class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { 7 var$post_id;8 var$parent_comment_id;9 var$parent_comment_data;10 var$child_comment_id;11 var$child_comment_data;7 protected static $post_id; 8 protected static $parent_comment_id; 9 protected static $parent_comment_data; 10 protected static $child_comment_id; 11 protected static $child_comment_data; 12 12 13 function setUp() {14 parent::setUp();13 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 14 self::$post_id = $factory->post->create(); 15 15 16 $this->post_id = self::factory()->post->create(); 17 18 $this->parent_comment_data = array( 19 'comment_post_ID' => $this->post_id, 16 self::$parent_comment_data = array( 17 'comment_post_ID' => self::$post_id, 20 18 'comment_author' => 'Test commenter', 21 19 'comment_author_url' => 'http://example.com/', … … 23 21 'comment_content' => rand_str( 100 ), 24 22 ); 25 $this->parent_comment_id = wp_insert_comment( $this->parent_comment_data );23 self::$parent_comment_id = wp_insert_comment( self::$parent_comment_data ); 26 24 27 $this->child_comment_data = array(28 'comment_post_ID' => $this->post_id,25 self::$child_comment_data = array( 26 'comment_post_ID' => self::$post_id, 29 27 'comment_author' => 'Test commenter 2', 30 28 'comment_author_url' => 'http://example.org/', 31 29 'comment_author_email' => 'example@example.org', 32 'comment_parent' => $this->parent_comment_id,30 'comment_parent' => self::$parent_comment_id, 33 31 'comment_content' => rand_str( 100 ) 34 32 ); 35 $this->child_comment_id = wp_insert_comment( $this->child_comment_data );33 self::$child_comment_id = wp_insert_comment( self::$child_comment_data ); 36 34 } 37 35 38 36 function test_invalid_username_password() { 39 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', $this->parent_comment_id ) );37 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) ); 40 38 $this->assertInstanceOf( 'IXR_Error', $result ); 41 39 $this->assertEquals( 403, $result->code ); … … 45 43 $this->make_user_by_role( 'contributor' ); 46 44 47 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', $this->parent_comment_id ) );45 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) ); 48 46 $this->assertInstanceOf( 'IXR_Error', $result ); 49 47 $this->assertEquals( 403, $result->code ); … … 53 51 $this->make_user_by_role( 'editor' ); 54 52 55 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', $this->parent_comment_id ) );53 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$parent_comment_id ) ); 56 54 $this->assertNotInstanceOf( 'IXR_Error', $result ); 57 55 … … 77 75 $this->assertStringMatchesFormat( '%d', $result['parent'] ); 78 76 $this->assertStringMatchesFormat( '%d', $result['post_id'] ); 79 $this->assertEquals( $this->parent_comment_id, $result['comment_id'] );77 $this->assertEquals( self::$parent_comment_id, $result['comment_id'] ); 80 78 $this->assertEquals( 0, $result['parent'] ); 81 $this->assertEquals( $this->parent_comment_data['comment_content'], $result['content'] );82 $this->assertEquals( $this->post_id, $result['post_id'] );83 $this->assertEquals( $this->parent_comment_data['comment_author'], $result['author'] );84 $this->assertEquals( $this->parent_comment_data['comment_author_url'], $result['author_url'] );85 $this->assertEquals( $this->parent_comment_data['comment_author_email'], $result['author_email'] );79 $this->assertEquals( self::$parent_comment_data['comment_content'], $result['content'] ); 80 $this->assertEquals( self::$post_id, $result['post_id'] ); 81 $this->assertEquals( self::$parent_comment_data['comment_author'], $result['author'] ); 82 $this->assertEquals( self::$parent_comment_data['comment_author_url'], $result['author_url'] ); 83 $this->assertEquals( self::$parent_comment_data['comment_author_email'], $result['author_email'] ); 86 84 } 87 85 … … 89 87 $this->make_user_by_role( 'editor' ); 90 88 91 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', $this->child_comment_id ) );89 $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) ); 92 90 $this->assertNotInstanceOf( 'IXR_Error', $result ); 93 91 94 $this->assertEquals( $this->child_comment_id, $result['comment_id'] );95 $this->assertEquals( $this->parent_comment_id, $result['parent'] );92 $this->assertEquals( self::$child_comment_id, $result['comment_id'] ); 93 $this->assertEquals( self::$parent_comment_id, $result['parent'] ); 96 94 } 97 95
Note: See TracChangeset
for help on using the changeset viewer.