Changeset 64350 for trunk/tests/phpunit/tests/http/http.php
- Timestamp:
- 10/14/2026 11:44:46 PM (5 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/http/http.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/http.php
r62593 r64350 697 697 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar['1'] ); 698 698 } 699 700 /** 701 * Tests that {@see WP_Http::normalize_cookies()} skips a cookie without a value, as {@see WP_Http_Cookie::getHeaderValue()} does. 702 * 703 * @covers WP_Http::normalize_cookies 704 */ 705 public function test_normalize_cookies_skips_cookie_without_value(): void { 706 $cookie = new WP_Http_Cookie( array( 'name' => 'flavor' ) ); 707 $this->assertNull( $cookie->value, 'Expected the cookie value to be null.' ); 708 $this->assertSame( '', $cookie->getHeaderValue(), 'Expected the cookie to be omitted from the header value.' ); 709 710 $cookie_jar = WP_Http::normalize_cookies( array( $cookie ) ); 711 712 $this->assertSame( array(), iterator_to_array( $cookie_jar ) ); 713 } 714 715 /** 716 * Tests that {@see WP_Http::normalize_cookies()} skips a cookie with a non-scalar value. 717 * 718 * @covers WP_Http::normalize_cookies 719 */ 720 public function test_normalize_cookies_skips_cookie_with_non_scalar_value(): void { 721 $cookie = new WP_Http_Cookie( 722 array( 723 'name' => 'prefs', 724 'value' => array( 'a' => 1 ), 725 ) 726 ); 727 728 $cookie_jar = WP_Http::normalize_cookies( array( $cookie ) ); 729 730 $this->assertSame( array(), iterator_to_array( $cookie_jar ) ); 731 } 732 733 /** 734 * Tests that {@see WP_Http::normalize_cookies()} sends a cookie with a scalar value as a string. 735 * 736 * @covers WP_Http::normalize_cookies 737 */ 738 public function test_normalize_cookies_casts_scalar_cookie_value_to_string(): void { 739 $cookie = new WP_Http_Cookie( 740 array( 741 'name' => 'count', 742 'value' => 5, 743 ) 744 ); 745 746 $cookie_jar = WP_Http::normalize_cookies( array( $cookie ) ); 747 748 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar['count'] ); 749 $this->assertSame( '5', $cookie_jar['count']->value ); 750 } 751 752 /** 753 * Tests that {@see WP_Http::normalize_cookies()} sends a cookie with an empty value. 754 * 755 * @covers WP_Http::normalize_cookies 756 */ 757 public function test_normalize_cookies_sends_cookie_with_empty_value(): void { 758 $cookie = new WP_Http_Cookie( 759 array( 760 'name' => 'flavor', 761 'value' => '', 762 ) 763 ); 764 $this->assertSame( 'flavor=', $cookie->getHeaderValue(), 'Expected the cookie to be in the header value.' ); 765 766 $cookie_jar = WP_Http::normalize_cookies( array( $cookie ) ); 767 768 $this->assertInstanceOf( 'WpOrg\Requests\Cookie', $cookie_jar['flavor'] ); 769 $this->assertSame( 'flavor=', $cookie_jar['flavor']->format_for_header() ); 770 } 699 771 }
Note:
See TracChangeset
for help on using the changeset viewer.