@@ 421-439 (lines=19) @@ | ||
418 | $this->check_get_user_response( $data, 'edit' ); |
|
419 | } |
|
420 | ||
421 | public function test_get_user_avatar_urls() { |
|
422 | wp_set_current_user( $this->user ); |
|
423 | ||
424 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->editor ) ); |
|
425 | ||
426 | $response = $this->server->dispatch( $request ); |
|
427 | ||
428 | $data = $response->get_data(); |
|
429 | $this->assertArrayHasKey( 24, $data['avatar_urls'] ); |
|
430 | $this->assertArrayHasKey( 48, $data['avatar_urls'] ); |
|
431 | $this->assertArrayHasKey( 96, $data['avatar_urls'] ); |
|
432 | ||
433 | $user = get_user_by( 'id', $this->editor ); |
|
434 | /** |
|
435 | * Ignore the subdomain, since 'get_avatar_url randomly sets the Gravatar |
|
436 | * server when building the url string. |
|
437 | */ |
|
438 | $this->assertEquals( substr( get_avatar_url( $user->user_email ), 9 ), substr( $data['avatar_urls'][96], 9 ) ); |
|
439 | } |
|
440 | ||
441 | public function test_get_user_invalid_id() { |
|
442 | wp_set_current_user( $this->user ); |
@@ 536-552 (lines=17) @@ | ||
533 | $this->check_comment_data( $data, 'edit', $response->get_links() ); |
|
534 | } |
|
535 | ||
536 | public function test_get_comment_author_avatar_urls() { |
|
537 | $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) ); |
|
538 | ||
539 | $response = $this->server->dispatch( $request ); |
|
540 | ||
541 | $data = $response->get_data(); |
|
542 | $this->assertArrayHasKey( 24, $data['author_avatar_urls'] ); |
|
543 | $this->assertArrayHasKey( 48, $data['author_avatar_urls'] ); |
|
544 | $this->assertArrayHasKey( 96, $data['author_avatar_urls'] ); |
|
545 | ||
546 | $comment = get_comment( $this->approved_id ); |
|
547 | /** |
|
548 | * Ignore the subdomain, since 'get_avatar_url randomly sets the Gravatar |
|
549 | * server when building the url string. |
|
550 | */ |
|
551 | $this->assertEquals( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) ); |
|
552 | } |
|
553 | ||
554 | public function test_get_comment_invalid_id() { |
|
555 | $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); |