Make WordPress Core

Ticket #40347: 40347.diff

File 40347.diff, 1.3 KB (added by TimothyBlynJacobs, 9 years ago)
  • src/wp-includes/rest-api/class-wp-rest-request.php

    diff --git a/src/wp-includes/rest-api/class-wp-rest-request.php b/src/wp-includes/rest-api/class-wp-rest-request.php
    index 9360cca..6b1cbef 100644
    a b class WP_REST_Request implements ArrayAccess { 
    286286         * @param string $key Header name.
    287287         */
    288288        public function remove_header( $key ) {
     289                $key = $this->canonicalize_header_name( $key );
    289290                unset( $this->headers[ $key ] );
    290291        }
    291292
  • tests/phpunit/tests/rest-api/rest-request.php

    diff --git a/tests/phpunit/tests/rest-api/rest-request.php b/tests/phpunit/tests/rest-api/rest-request.php
    index a96bbb0..4187526 100644
    a b class Tests_REST_Request extends WP_UnitTestCase { 
    3030                $this->assertNull( $this->request->get_header( 'missing' ) );
    3131                $this->assertNull( $this->request->get_header_as_array( 'missing' ) );
    3232        }
     33       
     34        public function test_remove_header() {
     35                $this->request->add_header( 'Test-Header', 'value' );
     36                $this->assertEquals( 'value', $this->request->get_header( 'Test-Header' ) );
     37               
     38                $this->request->remove_header( 'Test-Header' );
     39                $this->assertNull( $this->request->get_header( 'Test-Header' ) );
     40        }
    3341
    3442        public function test_header_multiple() {
    3543                $value1 = 'application/x-wp-example-1';