Changeset 57501
- Timestamp:
- 01/31/2024 12:51:39 PM (12 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-http.php
r56723 r57501 468 468 } 469 469 ); 470 $cookie_jar[ $value->name ] = new WpOrg\Requests\Cookie( $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) );470 $cookie_jar[ $value->name ] = new WpOrg\Requests\Cookie( (string) $value->name, $value->value, $attributes, array( 'host-only' => $value->host_only ) ); 471 471 } elseif ( is_scalar( $value ) ) { 472 $cookie_jar[ $name ] = new WpOrg\Requests\Cookie( $name, (string) $value );472 $cookie_jar[ $name ] = new WpOrg\Requests\Cookie( (string) $name, (string) $value ); 473 473 } 474 474 } -
trunk/tests/phpunit/tests/http/http.php
r56559 r57501 662 662 $this->assertTrue( $pre_http_request_filter_has_run, 'The pre_http_request filter is expected to run.' ); 663 663 } 664 665 /** 666 * Test that WP_Http::normalize_cookies method correctly casts integer keys to string. 667 * @ticket 58566 668 * 669 * @covers WP_Http::normalize_cookies 670 */ 671 public function test_normalize_cookies_casts_integer_keys_to_string() { 672 $http = _wp_http_get_object(); 673 674 $cookies = array( 675 '1' => 'foo', 676 2 => 'bar', 677 'qux' => 7, 678 ); 679 680 $cookie_jar = $http->normalize_cookies( $cookies ); 681 682 $this->assertInstanceOf( 'WpOrg\Requests\Cookie\Jar', $cookie_jar ); 683 684 foreach ( array_keys( $cookies ) as $cookie ) { 685 if ( is_string( $cookie ) ) { 686 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar[ $cookie ] ); 687 } else { 688 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar[ (string) $cookie ] ); 689 } 690 } 691 } 692 693 /** 694 * Test that WP_Http::normalize_cookies method correctly casts integer cookie names to strings. 695 * @ticket 58566 696 * 697 * @covers WP_Http::normalize_cookies 698 */ 699 public function test_normalize_cookies_casts_cookie_name_integer_to_string() { 700 $http = _wp_http_get_object(); 701 702 $cookies = array( 703 'foo' => new WP_Http_Cookie( 704 array( 705 'name' => 1, 706 'value' => 'foo', 707 ) 708 ), 709 ); 710 711 $cookie_jar = $http->normalize_cookies( $cookies ); 712 713 $this->assertInstanceOf( 'WpOrg\Requests\Cookie\Jar', $cookie_jar ); 714 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar['1'] ); 715 } 664 716 }
Note: See TracChangeset
for help on using the changeset viewer.