- Timestamp:
- 12/21/2021 02:43:18 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php
r51657 r52398 948 948 949 949 /** 950 * @ticket 53658 951 * 952 * @covers ::wp_is_application_passwords_supported 953 */ 954 public function test_wp_is_application_passwords_supported_with_https_only() { 955 $_SERVER['HTTPS'] = 'on'; 956 $this->assertTrue( wp_is_application_passwords_supported() ); 957 } 958 959 /** 960 * @ticket 53658 961 * 962 * @covers ::wp_is_application_passwords_supported 963 */ 964 public function test_wp_is_application_passwords_supported_with_local_environment_only() { 965 putenv( 'WP_ENVIRONMENT_TYPE=local' ); 966 967 $actual = wp_is_application_passwords_supported(); 968 969 // Revert to default behaviour so that other tests are not affected. 970 putenv( 'WP_ENVIRONMENT_TYPE' ); 971 972 $this->assertTrue( $actual ); 973 } 974 975 /** 976 * @dataProvider data_wp_is_application_passwords_available 977 * 978 * @ticket 53658 979 * 980 * @covers ::wp_is_application_passwords_available 981 * 982 * @param bool|string $expected The expected value. 983 * @param string|null $callback Optional. The callback for the `wp_is_application_passwords_available` hook. 984 * Default: null. 985 */ 986 public function test_wp_is_application_passwords_available( $expected, $callback = null ) { 987 remove_filter( 'wp_is_application_passwords_available', '__return_true' ); 988 989 if ( $callback ) { 990 add_filter( 'wp_is_application_passwords_available', $callback ); 991 } 992 993 if ( 'default' === $expected ) { 994 putenv( 'WP_ENVIRONMENT_TYPE=local' ); 995 $expected = wp_is_application_passwords_supported(); 996 } 997 998 $actual = wp_is_application_passwords_available(); 999 1000 if ( 'default' === $expected ) { 1001 // Revert to default behaviour so that other tests are not affected. 1002 putenv( 'WP_ENVIRONMENT_TYPE' ); 1003 } 1004 1005 $this->assertSame( $expected, $actual ); 1006 } 1007 1008 /** 1009 * Data provider. 1010 * 1011 * @return array 1012 */ 1013 public function data_wp_is_application_passwords_available() { 1014 return array( 1015 'availability not forced' => array( 1016 'expected' => 'default', 1017 ), 1018 'availability forced true' => array( 1019 'expected' => true, 1020 'callback' => '__return_true', 1021 ), 1022 'availability forced false' => array( 1023 'expected' => false, 1024 'callback' => '__return_false', 1025 ), 1026 ); 1027 } 1028 1029 /** 950 1030 * Sets up a REST API request to be authenticated using an App Password. 951 1031 *
Note: See TracChangeset
for help on using the changeset viewer.