wpRemoteRetrieveHeaders.php 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @group http
  4. * @covers ::wp_remote_retrieve_headers
  5. */
  6. class Tests_HTTP_wpRemoteRetrieveHeaders extends WP_UnitTestCase {
  7. /**
  8. * Valid response
  9. */
  10. function test_remote_retrieve_headers_valid_response() {
  11. $headers = 'headers_data';
  12. $response = array( 'headers' => $headers );
  13. $result = wp_remote_retrieve_headers( $response );
  14. $this->assertSame( $headers, $result );
  15. }
  16. /**
  17. * Response is a WP_Error
  18. */
  19. function test_remote_retrieve_headers_is_error() {
  20. $response = new WP_Error( 'Some error' );
  21. $result = wp_remote_retrieve_headers( $response );
  22. $this->assertSame( array(), $result );
  23. }
  24. /**
  25. * Response does not contain 'headers'
  26. */
  27. function test_remote_retrieve_headers_invalid_response() {
  28. $response = array( 'no_headers' => 'set' );
  29. $result = wp_remote_retrieve_headers( $response );
  30. $this->assertSame( array(), $result );
  31. }
  32. }