Changeset 59517 for trunk/tests/phpunit/tests/https-detection.php
- Timestamp:
- 12/16/2024 02:06:05 PM (22 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/https-detection.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/https-detection.php
r56664 r59517 42 42 */ 43 43 public function test_wp_is_https_supported() { 44 // The function works with cached errors, so only test that here. 45 $wp_error = new WP_Error(); 44 // Simulate that HTTPS is supported by returning an empty error array. 45 add_filter( 46 'pre_wp_get_https_detection_errors', 47 function () { 48 return new WP_Error(); // No errors means HTTPS is supported. 49 } 50 ); 46 51 47 52 // No errors, so HTTPS is supported. 48 update_option( 'https_detection_errors', $wp_error->errors );49 53 $this->assertTrue( wp_is_https_supported() ); 50 54 51 // Errors, so HTTPS is not supported. 52 $wp_error->add( 'ssl_verification_failed', 'SSL verification failed.' ); 53 update_option( 'https_detection_errors', $wp_error->errors ); 55 // Now we simulate that HTTPS is not supported by returning errors. 56 $support_errors = new WP_Error(); 57 $support_errors->add( 'ssl_verification_failed', 'SSL verification failed.' ); 58 59 // Short-circuit the detection logic to return our simulated errors. 60 add_filter( 61 'pre_wp_get_https_detection_errors', 62 function () use ( $support_errors ) { 63 return $support_errors; 64 } 65 ); 66 67 // Test that HTTPS is not supported due to the simulated errors. 54 68 $this->assertFalse( wp_is_https_supported() ); 69 70 // Remove the filter to avoid affecting other tests. 71 remove_filter( 'pre_wp_get_https_detection_errors', '__return_null' ); 55 72 } 56 73
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)