Changeset 42343 for trunk/tests/phpunit/tests/xmlrpc/wp/getComments.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/xmlrpc/wp/getComments.php
r40417 r42343 30 30 $this->assertNotIXRError( $results ); 31 31 32 foreach ( $results as $result ) {32 foreach ( $results as $result ) { 33 33 $comment = get_comment( $result['comment_id'], ARRAY_A ); 34 34 $this->assertEquals( $comment['comment_post_ID'], $result['post_id'] ); … … 42 42 $this->make_user_by_role( 'editor' ); 43 43 44 $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 45 'post_id' => $this->post_id 46 ) ) ); 44 $results = $this->myxmlrpcserver->wp_getComments( 45 array( 46 1, 47 'editor', 48 'editor', 49 array( 50 'post_id' => $this->post_id, 51 ), 52 ) 53 ); 47 54 $this->assertNotIXRError( $results ); 48 55 49 foreach ( $results as $result ) {56 foreach ( $results as $result ) { 50 57 $this->assertEquals( $this->post_id, $result['post_id'] ); 51 58 } … … 58 65 $this->make_user_by_role( 'editor' ); 59 66 60 $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 61 'post_id' => $this->post_id, 62 ) ) ); 67 $results = $this->myxmlrpcserver->wp_getComments( 68 array( 69 1, 70 'editor', 71 'editor', 72 array( 73 'post_id' => $this->post_id, 74 ), 75 ) 76 ); 63 77 $this->assertNotIXRError( $results ); 64 78 … … 66 80 $this->assertCount( 10, $results ); 67 81 68 $results2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 69 'post_id' => $this->post_id, 70 'number' => 5 71 ) ) ); 82 $results2 = $this->myxmlrpcserver->wp_getComments( 83 array( 84 1, 85 'editor', 86 'editor', 87 array( 88 'post_id' => $this->post_id, 89 'number' => 5, 90 ), 91 ) 92 ); 72 93 $this->assertNotIXRError( $results2 ); 73 94 $this->assertCount( 5, $results2 ); … … 76 97 function test_contributor_capabilities() { 77 98 $this->make_user_by_role( 'contributor' ); 78 $author_id = $this->make_user_by_role( 'author' ); 79 $author_post_id = self::factory()->post->create( array( 80 'post_title' => 'Author', 81 'post_author' => $author_id, 82 'post_status' => 'publish' 83 ) ); 84 85 self::factory()->comment->create( array( 86 'comment_post_ID' => $author_post_id, 87 'comment_author' => "Commenter 1", 88 'comment_author_url' => "http://example.com/1/", 89 'comment_approved' => 0, 90 ) ); 91 92 $editor_id = $this->make_user_by_role( 'editor' ); 93 $editor_post_id = self::factory()->post->create( array( 94 'post_title' => 'Editor', 95 'post_author' => $editor_id, 96 'post_status' => 'publish' 97 ) ); 98 99 self::factory()->comment->create( array( 100 'comment_post_ID' => $editor_post_id, 101 'comment_author' => 'Commenter 2', 102 'comment_author_url' => 'http://example.com/2/', 103 'comment_approved' => 0, 104 ) ); 99 $author_id = $this->make_user_by_role( 'author' ); 100 $author_post_id = self::factory()->post->create( 101 array( 102 'post_title' => 'Author', 103 'post_author' => $author_id, 104 'post_status' => 'publish', 105 ) 106 ); 107 108 self::factory()->comment->create( 109 array( 110 'comment_post_ID' => $author_post_id, 111 'comment_author' => 'Commenter 1', 112 'comment_author_url' => 'http://example.com/1/', 113 'comment_approved' => 0, 114 ) 115 ); 116 117 $editor_id = $this->make_user_by_role( 'editor' ); 118 $editor_post_id = self::factory()->post->create( 119 array( 120 'post_title' => 'Editor', 121 'post_author' => $editor_id, 122 'post_status' => 'publish', 123 ) 124 ); 125 126 self::factory()->comment->create( 127 array( 128 'comment_post_ID' => $editor_post_id, 129 'comment_author' => 'Commenter 2', 130 'comment_author_url' => 'http://example.com/2/', 131 'comment_approved' => 0, 132 ) 133 ); 105 134 106 135 $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor' ) ); … … 110 139 111 140 function test_author_capabilities() { 112 $author_id = $this->make_user_by_role( 'author' ); 113 $author_post_id = self::factory()->post->create( array( 114 'post_title' => 'Author', 115 'post_author' => $author_id, 116 'post_status' => 'publish' 117 ) ); 118 119 self::factory()->comment->create( array( 120 'comment_post_ID' => $author_post_id, 121 'comment_author' => 'Commenter 1', 122 'comment_author_url' => 'http://example.com/1/', 123 'comment_approved' => 1, 124 ) ); 125 126 $editor_id = $this->make_user_by_role( 'editor' ); 127 $editor_post_id = self::factory()->post->create( array( 128 'post_title' => 'Editor', 129 'post_author' => $editor_id, 130 'post_status' => 'publish' 131 ) ); 132 133 self::factory()->comment->create( array( 134 'comment_post_ID' => $editor_post_id, 135 'comment_author' => 'Commenter 2', 136 'comment_author_url' => 'http://example.com/2/', 137 'comment_approved' => 0, 138 ) ); 139 140 $result1 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 141 'post_id' => $author_post_id 142 ) ) ); 141 $author_id = $this->make_user_by_role( 'author' ); 142 $author_post_id = self::factory()->post->create( 143 array( 144 'post_title' => 'Author', 145 'post_author' => $author_id, 146 'post_status' => 'publish', 147 ) 148 ); 149 150 self::factory()->comment->create( 151 array( 152 'comment_post_ID' => $author_post_id, 153 'comment_author' => 'Commenter 1', 154 'comment_author_url' => 'http://example.com/1/', 155 'comment_approved' => 1, 156 ) 157 ); 158 159 $editor_id = $this->make_user_by_role( 'editor' ); 160 $editor_post_id = self::factory()->post->create( 161 array( 162 'post_title' => 'Editor', 163 'post_author' => $editor_id, 164 'post_status' => 'publish', 165 ) 166 ); 167 168 self::factory()->comment->create( 169 array( 170 'comment_post_ID' => $editor_post_id, 171 'comment_author' => 'Commenter 2', 172 'comment_author_url' => 'http://example.com/2/', 173 'comment_approved' => 0, 174 ) 175 ); 176 177 $result1 = $this->myxmlrpcserver->wp_getComments( 178 array( 179 1, 180 'author', 181 'author', 182 array( 183 'post_id' => $author_post_id, 184 ), 185 ) 186 ); 143 187 $this->assertIXRError( $result1 ); 144 188 145 $result2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 146 'status' => 'approve', 147 'post_id' => $author_post_id 148 ) ) ); 189 $result2 = $this->myxmlrpcserver->wp_getComments( 190 array( 191 1, 192 'author', 193 'author', 194 array( 195 'status' => 'approve', 196 'post_id' => $author_post_id, 197 ), 198 ) 199 ); 149 200 150 201 $this->assertInternalType( 'array', $result2 ); 151 202 $this->assertCount( 1, $result2 ); 152 203 153 $result3 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 154 'post_id' => $editor_post_id 155 ) ) ); 204 $result3 = $this->myxmlrpcserver->wp_getComments( 205 array( 206 1, 207 'author', 208 'author', 209 array( 210 'post_id' => $editor_post_id, 211 ), 212 ) 213 ); 156 214 $this->assertIXRError( $result3 ); 157 215 158 $result4 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array( 159 'status' => 'approve', 160 'post_id' => $author_post_id 161 ) ) ); 216 $result4 = $this->myxmlrpcserver->wp_getComments( 217 array( 218 1, 219 'author', 220 'author', 221 array( 222 'status' => 'approve', 223 'post_id' => $author_post_id, 224 ), 225 ) 226 ); 162 227 163 228 $this->assertInternalType( 'array', $result4 ); … … 166 231 167 232 function test_editor_capabilities() { 168 $author_id = $this->make_user_by_role( 'author' ); 169 $author_post_id = self::factory()->post->create( array( 170 'post_title' => 'Author', 171 'post_author' => $author_id, 172 'post_status' => 'publish' 173 ) ); 174 175 self::factory()->comment->create( array( 176 'comment_post_ID' => $author_post_id, 177 'comment_author' => 'Commenter 1', 178 'comment_author_url' => 'http://example.com/1/', 179 'comment_approved' => 1, 180 )); 181 182 $editor_id = $this->make_user_by_role( 'editor' ); 183 $editor_post_id = self::factory()->post->create( array( 184 'post_title' => 'Editor', 185 'post_author' => $editor_id, 186 'post_status' => 'publish' 187 ) ); 188 189 self::factory()->comment->create(array( 190 'comment_post_ID' => $editor_post_id, 191 'comment_author' => 'Commenter 2', 192 'comment_author_url' => 'http://example.com/2/', 193 'comment_approved' => 0, 194 )); 195 196 $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 197 'post_id' => $author_post_id 198 ) ) ); 233 $author_id = $this->make_user_by_role( 'author' ); 234 $author_post_id = self::factory()->post->create( 235 array( 236 'post_title' => 'Author', 237 'post_author' => $author_id, 238 'post_status' => 'publish', 239 ) 240 ); 241 242 self::factory()->comment->create( 243 array( 244 'comment_post_ID' => $author_post_id, 245 'comment_author' => 'Commenter 1', 246 'comment_author_url' => 'http://example.com/1/', 247 'comment_approved' => 1, 248 ) 249 ); 250 251 $editor_id = $this->make_user_by_role( 'editor' ); 252 $editor_post_id = self::factory()->post->create( 253 array( 254 'post_title' => 'Editor', 255 'post_author' => $editor_id, 256 'post_status' => 'publish', 257 ) 258 ); 259 260 self::factory()->comment->create( 261 array( 262 'comment_post_ID' => $editor_post_id, 263 'comment_author' => 'Commenter 2', 264 'comment_author_url' => 'http://example.com/2/', 265 'comment_approved' => 0, 266 ) 267 ); 268 269 $result = $this->myxmlrpcserver->wp_getComments( 270 array( 271 1, 272 'editor', 273 'editor', 274 array( 275 'post_id' => $author_post_id, 276 ), 277 ) 278 ); 199 279 $this->assertInternalType( 'array', $result ); 200 280 $this->assertCount( 1, $result ); 201 281 202 $result2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array( 203 'status' => 'approve', 204 'post_id' => $author_post_id 205 ) ) ); 282 $result2 = $this->myxmlrpcserver->wp_getComments( 283 array( 284 1, 285 'editor', 286 'editor', 287 array( 288 'status' => 'approve', 289 'post_id' => $author_post_id, 290 ), 291 ) 292 ); 206 293 207 294 $this->assertInternalType( 'array', $result2 );
Note: See TracChangeset
for help on using the changeset viewer.